
Bug hunt
Fix the Signpost
Some characters are hard to type inside a string. A
backslash \ starts an escape sequence:
| Escape | Means |
|---|---|
\n |
new line |
\t |
tab |
\" / \' |
a quote that doesn't end the string |
\\ |
one real backslash |
print("Pip said \"hi\"\nand waved")
# Pip said "hi"
# and waved
For text with many lines, triple quotes let you write the new lines directly:
sign = """Line one
Line two"""
Beware Windows-style paths! In "C:\new", the \n becomes a
new line. To get a real backslash, write "C:\\new".
Assignment
The signpost program crashes. Fix the strings so that
print(sign) shows exactly (with a tab after Open:):
Welcome to "The Glow"
Open: dusk to dawn
Map: C:\new\trails
Keep building sign from its three pieces, then print it.
The signpost program crashes. Fix the strings so that
print(sign) shows exactly (with a tab after Open:):
Welcome to "The Glow"
Open: dusk to dawn
Map: C:\new\trails
Keep building sign from its three pieces, then print it.
main.py Python sleeping
Press Run to try your code, then Check to test it.