[Tutor] Trailing spaces affect output in a way I don't understand.
boB Stepp
robertvstepp at gmail.com
Sun Dec 16 05:16:45 CET 2012
In the following code:
print(
"""
______ ____ ___ ___ ______
/ _____| / | / |/ | | ____|
| | / /| | / /| /| | | |__
| | _ / ___ | / / |__/ | | | __|
| |__| | / / | | / / | | | |___
\______/ /__/ |_| /_/ |_| |______|
______ __ _ ______ ______
/ _ \ | | / / | ___| | _ \
| | | | | | / / | |__ | |_| |
| | | | | | / / | __| | _ /
| |_| | | | / / | |___ | | \ \
\______/ |_____/ |______| |__| \_\
"""
)
All trailing spaces have been trimmed off the end of the lines. It
results in the following undesired output:
______ ____ ___ ___ ______
/ _____| / | / |/ | | ____|
| | / /| | / /| /| | | |__
| | _ / ___ | / / |__/ | | | __|
| |__| | / / | | / / | | | |___
\______/ /__/ |_| /_/ |_| |______|
______ __ _ ______ ______
/ _ \ | | / / | ___| | _ | | | | | |
/ / | |__ | |_| |
| | | | | | / / | __| | _ /
| |_| | | | / / | |___ | | \ \______/
|_____/ |______| |__| \_
What greatly puzzles me is that "GAME" prints correctly, but "OVER"
does not. Why?
If I add trailing spaces to the lines that form "OVER" such that the
final space in each such line lines up vertically with the others that
form "OVER" then "OVER" prints correctly. I imagine I am being
incredibly dense here, but I cannot see why "GAME" prints correctly
with all trailing spaces removed, but "OVER" must have the correct
number of spaces at the end of each line, so that it works.
And the explanation is ???
boB
More information about the Tutor
mailing list