0

Question about tab in strings

print("\tHello World") print("\t Hello World") So I've noticed that both of these work, (except the second one has prints one space ahead of the first one) and I was wondering, how does the computer not get confused with print("\tHello World") since the t and the H are right next to one another?

23rd Aug 2020, 3:27 PM
Sahiba Kaur
Sahiba Kaur - avatar
2 Answers
+ 4
escape sequence(\) helps the computer to figure special meaning of \t (tabs) \n (newline) etc. How? once the computer sees a back-slash, it knows that the following character(like 't', 'n') has some special meaning.
23rd Aug 2020, 3:30 PM
minirkk
minirkk - avatar
+ 1
you used the escape character "\" when you use that, the next character is not considered a letter, but converts the character to whatever that character equals. "n" is equal to "n", but "\n" is a new line
23rd Aug 2020, 3:30 PM
Slick
Slick - avatar