2.1.1.12 Your very first program

The print() function - the escape and newline characters

This convention has two important consequences:
1. If you want to put just one backslash inside a string, don't forget its escaping nature - you have to double it, e.g., such an invocation will cause an error:
print("\")
while this one won't:
print("\\")
2. Not all escape pairs (the backslash coupled with another character) mean something.

Experiment with your code in the editor, run it, and see what happens.


print("The itsy bitsy spider\nclimbed up the waterspout.")
print()
print("Down came the rain\nand washed the spider out.")
  • Console 

Comments

Popular Posts