1
00:00:01,129 --> 00:00:08,510
Great! We have a working program now and
we added every feature that we wanted.

2
00:00:08,510 --> 00:00:14,790
The only problem now with the
program is that the output is not very

3
00:00:14,790 --> 00:00:23,250
user friendly. With that I mean you know
let's say yes here, so this is the output

4
00:00:23,250 --> 00:00:29,490
and you get a list here, so it's a
Python list and what we want to do

5
00:00:29,490 --> 00:00:35,309
instead is we want to show each of these
lines in one separate line in the

6
00:00:35,309 --> 00:00:40,890
terminal, so that output will be more
readable to the human eye.

7
00:00:40,890 --> 00:00:46,620
And let's go ahead and do that. So how
can we implement such a thing? So this

8
00:00:46,620 --> 00:00:56,550
output now is a list object which means
that the call here, the function call, this

9
00:00:56,550 --> 00:01:03,359
produces this list object and so what
can we do is we could maybe iterate

10
00:01:03,359 --> 00:01:10,380
through this list object, you know
something like we can store the list

11
00:01:10,380 --> 00:01:18,119
object in a variable. So output will be
assigned this list. And then what you can

12
00:01:18,119 --> 00:01:26,180
do is you can say for item in the list,
in the output list print out the item.

13
00:01:26,180 --> 00:01:33,600
Let's save this and try out. We're going
to have an issue here,

14
00:01:33,600 --> 00:01:37,710
but one step at a time.
Enter Y, yeas, Y.

15
00:01:37,710 --> 00:01:43,770
And so this is what I wanted to have so
the first definition precipitation in

16
00:01:43,770 --> 00:01:49,350
the form of liquid water goes in the
first line and the second definition to

17
00:01:49,350 --> 00:01:54,210
fall from the clouds in drops of water
and goes to the second line. So that's

18
00:01:54,210 --> 00:02:00,540
good, however we should keep in mind that
our program does not produce only lists,

19
00:02:00,540 --> 00:02:08,060
but sometimes it produces strings
as well so such as this one in here.

20
00:02:08,060 --> 00:02:18,510
No, I didn't mean that. Anyway, so this is what
you get and you don't want that. This is

21
00:02:18,510 --> 00:02:24,750
a message saying that the world doesn't
exist. So what the program is doing, what

22
00:02:24,750 --> 00:02:30,330
Python is doing is it is iterating
through all, every type of output that

23
00:02:30,330 --> 00:02:35,849
the function generates, so our function
generates a list sometimes and sometimes

24
00:02:35,849 --> 00:02:41,549
it generates a string.
How can we fix that? We have a list and

25
00:02:41,549 --> 00:02:44,640
a string.
Let's think of the difference, how can we

26
00:02:44,640 --> 00:02:48,840
discriminate a list from a string? What's
the difference between a list and a string?

27
00:02:48,840 --> 00:02:53,730
Well, the difference is clearly
the data type. A list is a list object

28
00:02:53,730 --> 00:03:00,569
and a string is a string object. So how
about implementing a conditional here? We

29
00:03:00,569 --> 00:03:19,109
say something like this. If type of
output is a list, then indent this

30
00:03:19,109 --> 00:03:25,560
with four spaces and that one as well.
So this loop now is nested inside that

31
00:03:25,560 --> 00:03:32,220
conditional and will be executed only
when this evaluates to true so only when

32
00:03:32,220 --> 00:03:42,750
we have, when we get returned a list from
the program so else it is not released

33
00:03:42,750 --> 00:03:48,859
it has to be a string so in the case we
want to print out the output without

34
00:03:48,859 --> 00:03:54,170
iterating through it. So let me check!
And we get the output correctly this

35
00:04:00,260 --> 00:04:04,609
time, the message: �The word doesn't exist.
Please double-check it�. Let's check

36
00:04:04,609 --> 00:04:12,939
another time with a correct word. And we
get the correct definitions in there.

37
00:04:12,939 --> 00:04:22,160
Let's try another world mathematics and
this time the mathematics world has only

38
00:04:22,160 --> 00:04:29,479
one definition so we get that definition
printed out in here so it's a science. Let's

39
00:04:29,479 --> 00:04:36,050
try the other scenario as well, rain.
Did you mean rain instead? No. The word

40
00:04:36,050 --> 00:04:42,259
doesn't exist. Please double-check it.
So we got this line here executed. So yeah,

41
00:04:42,259 --> 00:04:49,370
this is the complete code and I think we
can consider our program complete now, so

42
00:04:49,370 --> 00:04:54,110
that's what I thought of adding to the
program. Now the program is quite user

43
00:04:54,110 --> 00:04:58,910
friendly and we are considering many
scenarios there that the user may input

44
00:04:58,910 --> 00:05:06,830
to the program. However the interface is
still a command line interface, so it's

45
00:05:06,830 --> 00:05:13,580
not a desktop graphical program and it's
not a web application. The interface is a

46
00:05:13,580 --> 00:05:17,930
command line, so you send input through
the command line and you get output

47
00:05:17,930 --> 00:05:22,210
through the command line.
And what I'm trying to tell you that you

48
00:05:22,210 --> 00:05:27,850
can actually extend this program so that
you can transform it into a web

49
00:05:27,850 --> 00:05:31,720
application where the user instead of
entering the input through the command

50
00:05:31,720 --> 00:05:37,479
line, that I can enter input through
a web page, so through a live web site.

51
00:05:37,479 --> 00:05:43,599
They can enter input, push a button, and then
get the output dynamically on the HTML

52
00:05:43,599 --> 00:05:49,030
web page so that is possible with Python,
but you're still not ready to do that

53
00:05:49,030 --> 00:05:53,919
because we have quite a few more
sections to go, we have some application

54
00:05:53,919 --> 00:06:00,250
well I've teach you how to develop web
applications with Python. After that you

55
00:06:00,250 --> 00:06:07,449
can go back to this code and extend it
and create a web interface and also

56
00:06:07,449 --> 00:06:11,680
you'll be able to create a desktop
graphical user interface with the

57
00:06:11,680 --> 00:06:15,430
knowledge that you'll gain through these
sections because we're also covering

58
00:06:15,430 --> 00:06:20,800
graphical user interfaces in the course
and also we are also covering databases.

59
00:06:20,800 --> 00:06:25,930
So why I'm mentioning databases? Well,
because in this program we're using this

60
00:06:25,930 --> 00:06:31,389
file where to store our data set.
The problem with this is that if this gets

61
00:06:31,389 --> 00:06:36,130
too big, for now this is just five
megabytes, so that's good but if

62
00:06:36,130 --> 00:06:40,810
the file gets too big, then you
need to load the fall in Python every

63
00:06:40,810 --> 00:06:46,180
time you execute the script like here we
are loading the file into the Python

64
00:06:46,180 --> 00:06:50,979
session when you execute the script. Now
if the file is too big that will be very

65
00:06:50,979 --> 00:06:56,620
costly in terms of time, so what
you want to do that you want instead,

66
00:06:56,620 --> 00:07:02,050
you want to use a database maybe. With a database
what happens is that you make a query to

67
00:07:02,050 --> 00:07:07,810
the database and instead of getting the
entire data set you actually get only

68
00:07:07,810 --> 00:07:13,900
that row or that value which you queried
for, so databases are very efficient.

69
00:07:13,900 --> 00:07:18,610
I will cover databases later in the course
and so after a few sections I'll get back to

70
00:07:18,610 --> 00:07:24,909
this program. I'll give it to you as
an exercise so that you can extend it by

71
00:07:24,909 --> 00:07:29,380
creating and interface,
a graphical interface for that, or a web

72
00:07:29,380 --> 00:07:33,510
interface and also
I'll give you access to a database where

73
00:07:33,510 --> 00:07:38,610
you can query data for this program so
that it becomes a real robust with a

74
00:07:38,610 --> 00:07:43,680
very friendly user interface. So I hope
you like the idea and I hope you are

75
00:07:43,680 --> 00:07:49,770
enjoying the course and yeah let's move
on with some more sections.

76
00:07:49,770 --> 00:07:51,000
I'll see you later! Bye!

