In this video, you will learn one of the most important elements of the Python programming language,
and that is the full loop.
So why do we need a full loop in this program?
Well, when we execute the program and we add, for example, A to do clean and then we add another
one at.
Through.
And then every press show, what we get is.
A list.
So this is a list object and it's not very user friendly.
The user doesn't want to see brackets.
They want to see just text.
And they also don't want to see these quotes around the two two items.
So how can we output H to do in one line?
So 1 to 2 item per line without brackets, without commas, without quotes?
Well, to do that we need to print out each of the two dos using a print function.
So basically what we want to do is we want to go to the show case and instead of printing out the list
with delete that and we save four item in to dos print item.
So notice the level of indentation here.
So the while loop is at the very first level of indentation and then match is.
One level beneath that.
And then we have case.
At another level, then we have the full loop.
So the full loop is indented.
Three times one here, two and three.
And so print is part of that loop.
The function of this print function will be executed as many times as there are items in the to do list.
So let me run this.
Again at.
Clean at again.
Through.
And now I want to show.
Show presenter And there we go.
That's the output.
Clean and through.
So that's above the full loop.
We'll cover the full loop later on in the bonus example of.
But what I wanted to show also is how to make a small improvement of our program, because what happens
is that if you press add so the program is asking us to type in ADD, show or exit.
And if you press add and then maybe you make a space, a whitespace character and then you press enter
the program will not recognize.
That's because it is not ad it is ads plus whitespace.
So for Python that is a different string.
So add.
And add.
If you use this comparison.
Operator.
You get fools.
So those are not the same strings.
Well, if you say ad is equal to ad.
Yes, that is true.
So that is a comparison.
Operator is not it is not an assignment operator.
It compares two values to check if they are the same.
So how can we make our program more intelligent in this point?
Well, we can simply apply here.
A stream method which removes that trailing space from the string.
So for that we can use the strip method.
The strip method works like this.
Let's say the user action, which is a variable, will be equal to add with a space.
Then if you do user action that strip.
And you press enter, you get at without the space.
But know that if you call user action again.
You will again get at with the space.
So what happens here is that the strip method simply.
Returns a new string, but it does not change the string in the user action variable.
So if you want to save the changes to user action, you have to say user action equal to user action
that strip.
Execute.
That's now user action is going to be ad without the trailing space.
So this was just the Python console to have the changes in your code.
Of course, you need to input that expression.
So more in here.
So I think we should put it in here.
User action is equal to user action strip.
So we get adds, show or exits, and if AD has a trailing space, we strip it.
If show has a trailing space, which strip it out and so on for exit as well.
So at this point we get a clean command without spaces and then we match that to add show or exit.
So that was a nice addition to our program, and that's the for loop, which we will cover again later.
So that's about now.
See you later.