Hey, welcome back.
As you have noticed, through all the calls, we have been doing two main things, which is adding new
features and then improving the user experience.
So these are two phases that you have to go through over the lifecycle, the development lifecycle of
your program.
And in this video, we will be improving the user experience again.
What exactly will be doing is this?
So let's say the user is adding new to DOS in order to do list, and I show that to dos and they want
to add it to something.
But in order to say what they want to add it, they want to they have to count currently 1 to 3 and
maybe they decide on number three.
So they enter three there.
So we want to make this experience flawless.
We want to show numbers in front of each to do so that the user can simply look at the number and then
write the number there so they don't have to count.
How do we do that?
Well.
We have to look at where we are printing out those items, which is in here.
So we produce that list.
Using this for loop.
The for loop goes over to to dos and prints out its each item.
Now the solution to show numbers in front is the enumerate function.
Let me demonstrate to you what enumerate is.
So let's say we have to do list currently, which is let's say, clean through and do that.
At least we have this point.
So we have we have that list in here.
We want to show that.
So currently what we do is for item into dos print item.
Right.
We execute and we get the list.
Now, what we want to do is we want to go back in here and say Enumerate, which is a function.
And this function gets as inputs a list.
So the list goes as the inputs of enumerate, function and enumerate function now makes available not
only the items of the list, but also the indices of that list.
So we're going to get two elements from here.
Therefore, we need two variables for eye or index for index and item in enumerate to dos print item,
and we also print index.
So index and item to go down here, press enter.
And so this is what we get.
So what's happened is that we print out the index in the first iteration and also the item.
So in the first iteration, the full loop goes and gets it gets clean and it's index zero.
So it stores clean in the item variable and zero in the index variable.
And therefore and here we print out zero and clean.
It does the same for the other indexes and other items.
So let's go back to our code now and implement the same enumerate function.
So for index item in enumerate to do's print index item if you want, you can also add a third argument
in between here, which could be a string.
Single quotes should be enough dot perhaps, or a dash, whatever you like and let's see what we will
get.
So run, stop and rerun.
Add through, add, do show.
Yep, that's what we get.
So it's looking better.
Not ideal though.
I would prefer not to have these spaces or at least the space between the dash and through.
So how can we change the format of this text?
How can we remove that space?
Here.
We don't seem to have any spaces, so we don't have much control over this thing when we use this sprint
function.
But we can get control over that if we use F strings.
F strings is something we're going to be using in the next video.
So I'll talk to you there.