Exercises
Escape Characters
3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.
Exercise 1Passed
Print two lines from a single string, using an escape rather than two prints.
Python
# print first then second, from one print call
\n is a newline.
print("first\nsecond")Exercise 2Passed
Print the Windows path literally, backslashes and all.
Python
# print C:\temp\new\table.csv exactly
A raw string turns off escape sequences.
print(r"C:\temp\new\table.csv")Exercise 3Passed
Print the repr of the value so the tabs and newline are visible.
Python
value = "line\twith\ttabs\n"
# show the escapes
repr() shows a value the way you would write it in code.
value = "line\twith\ttabs\n"
print(repr(value))