Again the print statement

i am unable to understand he output of the statement
string=‘I study Python at Coding Blocks’
print(string[::-1])
and also the use of r in
print(r’Python\n is the \n best’)
#asking here because ask doubt is not working in the quiz tab

print(string[::-1])
will print the string in reverse order as the syntax for the same is -
[start:end:steps]
Here the steps indicate how you want to increment / decremented your indexes to access them , -1 will indicates that you want to decrement your string by -1 so it will end up printing your string in the reverse order.

print(r’Python\n is the \n best’)
In this statement r means that you want to print the raw string , so it will ignore all the escape characters and print the complete statement. So your output will be-
Python\n is the \n best

1 Like

ohk thanks u bhaiya for the help