1
00:00:00,520 --> 00:00:06,430
In this video, you will learn one of the most important elements of the Python programming language,

2
00:00:06,430 --> 00:00:08,350
and that is the full loop.

3
00:00:09,010 --> 00:00:12,670
So why do we need a full loop in this program?

4
00:00:12,760 --> 00:00:20,050
Well, when we execute the program and we add, for example, A to do clean and then we add another

5
00:00:20,050 --> 00:00:21,310
one at.

6
00:00:23,010 --> 00:00:23,820
Through.

7
00:00:24,340 --> 00:00:28,770
And then every press show, what we get is.

8
00:00:31,760 --> 00:00:33,110
A list.

9
00:00:33,410 --> 00:00:38,390
So this is a list object and it's not very user friendly.

10
00:00:38,810 --> 00:00:41,250
The user doesn't want to see brackets.

11
00:00:41,270 --> 00:00:43,460
They want to see just text.

12
00:00:43,460 --> 00:00:49,610
And they also don't want to see these quotes around the two two items.

13
00:00:50,120 --> 00:00:56,390
So how can we output H to do in one line?

14
00:00:56,390 --> 00:01:02,810
So 1 to 2 item per line without brackets, without commas, without quotes?

15
00:01:03,590 --> 00:01:13,130
Well, to do that we need to print out each of the two dos using a print function.

16
00:01:14,320 --> 00:01:22,990
So basically what we want to do is we want to go to the show case and instead of printing out the list

17
00:01:22,990 --> 00:01:33,490
with delete that and we save four item in to dos print item.

18
00:01:34,690 --> 00:01:38,830
So notice the level of indentation here.

19
00:01:39,850 --> 00:01:48,280
So the while loop is at the very first level of indentation and then match is.

20
00:01:50,250 --> 00:01:52,440
One level beneath that.

21
00:01:53,040 --> 00:01:54,810
And then we have case.

22
00:01:57,560 --> 00:02:02,390
At another level, then we have the full loop.

23
00:02:03,930 --> 00:02:06,270
So the full loop is indented.

24
00:02:06,270 --> 00:02:11,430
Three times one here, two and three.

25
00:02:14,180 --> 00:02:17,540
And so print is part of that loop.

26
00:02:17,570 --> 00:02:25,850
The function of this print function will be executed as many times as there are items in the to do list.

27
00:02:28,180 --> 00:02:29,650
So let me run this.

28
00:02:30,640 --> 00:02:33,220
Again at.

29
00:02:35,830 --> 00:02:38,320
Clean at again.

30
00:02:42,390 --> 00:02:43,140
Through.

31
00:02:43,320 --> 00:02:44,790
And now I want to show.

32
00:02:45,090 --> 00:02:48,020
Show presenter And there we go.

33
00:02:48,030 --> 00:02:49,050
That's the output.

34
00:02:50,550 --> 00:02:52,050
Clean and through.

35
00:02:53,630 --> 00:02:55,500
So that's above the full loop.

36
00:02:55,520 --> 00:03:00,100
We'll cover the full loop later on in the bonus example of.

37
00:03:00,110 --> 00:03:06,320
But what I wanted to show also is how to make a small improvement of our program, because what happens

38
00:03:06,320 --> 00:03:12,920
is that if you press add so the program is asking us to type in ADD, show or exit.

39
00:03:12,920 --> 00:03:18,860
And if you press add and then maybe you make a space, a whitespace character and then you press enter

40
00:03:19,130 --> 00:03:21,440
the program will not recognize.

41
00:03:23,220 --> 00:03:29,090
That's because it is not ad it is ads plus whitespace.

42
00:03:29,100 --> 00:03:32,580
So for Python that is a different string.

43
00:03:32,610 --> 00:03:34,920
So add.

44
00:03:37,620 --> 00:03:39,510
And add.

45
00:03:40,970 --> 00:03:42,770
If you use this comparison.

46
00:03:42,770 --> 00:03:43,640
Operator.

47
00:03:45,620 --> 00:03:46,730
You get fools.

48
00:03:46,730 --> 00:03:49,550
So those are not the same strings.

49
00:03:49,640 --> 00:03:54,850
Well, if you say ad is equal to ad.

50
00:03:56,330 --> 00:03:57,780
Yes, that is true.

51
00:03:57,800 --> 00:03:59,370
So that is a comparison.

52
00:03:59,390 --> 00:04:02,620
Operator is not it is not an assignment operator.

53
00:04:02,630 --> 00:04:06,290
It compares two values to check if they are the same.

54
00:04:06,860 --> 00:04:11,720
So how can we make our program more intelligent in this point?

55
00:04:13,340 --> 00:04:16,310
Well, we can simply apply here.

56
00:04:17,899 --> 00:04:23,390
A stream method which removes that trailing space from the string.

57
00:04:24,590 --> 00:04:27,110
So for that we can use the strip method.

58
00:04:27,260 --> 00:04:29,420
The strip method works like this.

59
00:04:30,350 --> 00:04:38,990
Let's say the user action, which is a variable, will be equal to add with a space.

60
00:04:39,400 --> 00:04:45,650
Then if you do user action that strip.

61
00:04:47,150 --> 00:04:51,350
And you press enter, you get at without the space.

62
00:04:51,830 --> 00:04:57,530
But know that if you call user action again.

63
00:04:59,330 --> 00:05:02,500
You will again get at with the space.

64
00:05:02,510 --> 00:05:06,830
So what happens here is that the strip method simply.

65
00:05:07,770 --> 00:05:15,390
Returns a new string, but it does not change the string in the user action variable.

66
00:05:17,310 --> 00:05:25,920
So if you want to save the changes to user action, you have to say user action equal to user action

67
00:05:26,130 --> 00:05:27,360
that strip.

68
00:05:29,940 --> 00:05:30,360
Execute.

69
00:05:30,360 --> 00:05:35,490
That's now user action is going to be ad without the trailing space.

70
00:05:35,940 --> 00:05:41,620
So this was just the Python console to have the changes in your code.

71
00:05:41,640 --> 00:05:45,810
Of course, you need to input that expression.

72
00:05:45,810 --> 00:05:47,100
So more in here.

73
00:05:48,360 --> 00:05:52,890
So I think we should put it in here.

74
00:05:52,950 --> 00:05:55,630
User action is equal to user action strip.

75
00:05:55,650 --> 00:06:04,020
So we get adds, show or exits, and if AD has a trailing space, we strip it.

76
00:06:04,050 --> 00:06:08,790
If show has a trailing space, which strip it out and so on for exit as well.

77
00:06:09,150 --> 00:06:18,600
So at this point we get a clean command without spaces and then we match that to add show or exit.

78
00:06:20,530 --> 00:06:27,380
So that was a nice addition to our program, and that's the for loop, which we will cover again later.

79
00:06:27,400 --> 00:06:28,690
So that's about now.

80
00:06:28,840 --> 00:06:29,740
See you later.

