In programming.
Whitespace refers to any non-printing characters such as spaces, tabs and end of line symbols.
You can use whitespace to organize your output so it's easier for users to read.
To add a tab to your text, use the character t.
Here now we will print.
He Oxley.
Now, we will see this here.
As you can see, we have a tab here.
So let's actually print the Oxley without tab and see how many characters we are seeing now.
Here.
As you can see here, this is accelerated.
This is auxiliary without the tab and this is auxiliary with the tab here.
To add new lines in a string.
You use the character n.
Here.
This is our new line.
So this here is N right here.
And you can also use combine tabs and newlines in a single string.
So now the string here.
Now let's actually end.
T or actually it's pride, right?
The languages.
So languages.
And here we will are Java Python and C plus plus.
So n t.
Python.
And here n t.
C plus plus and.
C plus plus and T and Java.
Now.
We will see this following output.
That's it.
As you can see here, we have tabs in here.
We have new lines in here, tabs, new lines.
And tabs.
So here actually, it doesn't work like that because as you can see, the first overwrite the new lines
and then tabs, new line tabs, new line tabs.
So it will work.
Firstly, new line here, then tab second.
New Line third EP.
Or new line shift and tab six here.
So that's it.
And the new license tabs will be very useful in the next few sections when you start to produce many
lines of output from just a few lines of code.
Now we can also strip the whitespaces in Python strings.
So let me actually look at the lecture time if we have time.
Yes, just at three minutes now.
So extra whitespace can be confusing for programs programmers.
Python.
The programmers python and here let's actually let's delete this for sorry.
So for programmers python and.
Python look pretty much the same, right?
But to a program they are two different actually.
So.
So so for program they are two different strings.
Python the takes the extra space in second python and considers it significant.
Unless you tell it otherwise.
It's important to think about whitespace because often you will want to compare two strings.
So determine whether they are the same.
For example, one important instance might involve checking people's username when they log into a website.
Right?
So extra whitespace can be confusing in much simpler situations as well.
Version of Python makes it easier to.
Illuminate.
Uh, extra whitespace from data that people enter.
So Python can look at for extra whitespace on the right and the left side of a string.
So to ensure that the whitespace no whitespace exists at the right side of a string.
So you can use our script now.
Uh, my my favorite language here is going to be.
Python.
And here we will use.
Ops.
Let's actually add whitespace here and now.
We will print the my favorite language.
And after that we will use my favorite language.
That.
Strip or strip or strip and that's it that we will print my favorite language.
Language again, my favorite language again.
And after that.
Yeah, that's it.
Yeah.
Now let's run this.
As you can see here, we got to.
Same results.
And here you will see that there is a white space here.
And if you select this like that, you have a white spaces here.
Because you in order to change this or show like this, you will write the script here and now you will
see this here.
Now Python is stripped.
So the value associated with my favorite language contains extra whitespace at the end of a string.
So when you ask Python for this value in a terminal session, you can see the whitespace at the end
of the value.
Right.
So when the answer methods acts on the variable, my favorite language, this extra space is removed,
as you can see here.
However, it's only removed temporarily.
So if you ask for the value of my favorite language, again right here, let's print my favorite language.
The strings.
Look, this looks the same here.
Here.
So this has whitespace.
This doesn't have whitespace here.
And also this has white space.
So.
As I said, if you ask the value again.
The strings look the same as when it was created, including the extra whitespace.
So to remove the whitespace from the string permanently, you have to associate the script value with
the variable name.
Now.
Let's.
Here.
After that, we will use instead of just writing the variable name like this.
Here writing variable name like this.
We will add this here.
My favorite language equals my favorite language, our script.
Now let's print the value.
Print my favorite language.
And here.
That's it.
So this is firstly the.
White space version.
And this is the version without the white space.
And as you can see, we didn't use the strip function in.
Um, my favorite language.
Because now, after this third line, my favorite language.
My favorite language is.
Value is equal to this.
Whenever you use it, this variable is the name of your my favorite language variable.
So.
In this example, we start with with the value that has whitespace at the beginning and let's actually
yes, yes.
It will be more good practice to use the whitespace on the beginning.
Right.
So now let's add whitespace at the beginning as well.
Now, as you can see here, yes, it would fix our white spaces at the end in the second here because
we don't have the white spaces here.
But I'm sorry.
Here we have white space here.
Button in the start, but not in the end.
So we have white spaces in second in the left, but not on the right.
But here we have white spaces on both sides.
So in order to fix this, we will use our strip here.
So.
Now we will use my favorite language again.
And after that, my favorite language.
That all strip, strip.
Now let's try this out.
And as you can see here, we deleted all the white spaces.
But in the first example that we without manipulation of our text you are seeing here, we have two
white spaces on the left and the right here.
But in the second, we don't have any white spaces here.
That's it.
Because we use these functions are strip and strip.