+ 1
What do i get as output if i type '\8' and '\1'?
It's showing different outputs. '\\8' and '\x01' respectively. Could anyone help me with an explanation of what it's actually doing?
2 Answers
+ 1
it must be showing either error or random symbols.
its because \ - escape characters actually hides next character from output and display their second meanings.
if we want to display \ then we can use \\ as \ has second meaning of itself.
but 8,1 dont have sexond meaning hence there may be random symbols or error
+ 1
\ is used to escape the literal meaning of anything for example " for termination of string
but when used with numbers it cannot escape it to another meaning so it is displayed as such
below are some examples:
print("i\n am\n spartan\"s") #espaces " in Spartans
print('\8') #considers it as string and prints \8
print(\8) #gives error as in \expects characters
>>> \8 #returns\\8