Python Forum

Full Version: Wrong output from script mode
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm at the beginning of the second lesson in the Python programming book "Python programming for the absolute beginner 3rd edition". The end product is supposed to look like this.

Programme 'Game Over' 2.0
Same message as before.
Just a bit bigger...
Output:
_____ ___ ___ ___ _____ / ___| / | / |/ | | ___| | | / /| | / /| /| | | |___ | | _ / ___ | / / |__/ | | | ___| | | | | / / | | / / | | | |___ \_____/ /_/ |_| /_/ |_| |_____| _____ _ _ _____ _____ / _ \ | | / / | ___| | _ \ | | | | | | / / | |___ | |_| | | | | | | | / / | ___| | _ / | |_| | | |/ / | |___ | | \ \ \_____/ |___/ |_____| |_| \_\ Press the enter key to exit.
Most of it works fine, except the way the word over appears, which is like this;
Output:
_____ _ _ _____ _____ / _ \ | | / / | ___| | _ | | | | | | / / | |___ | |_| | | | | | | | / / | ___| | _ / | |_| | | |/ / | | | | \ \_____/ |___/ |_____| |_| \_
What is causing this to happen and how can I fix it? I've tried doing this on 2 separate laptops, using Python 3.6.5 and on both the flaws are identical, so clearly it's the software, and not a problem with my laptop having trouble saving the file or something like that. EDIT: it doesn't even come out properly on here once I've posted the thread...

Thank you in advance for any help and advise you can give :).

Stephen.
If you put your output in output tags, It should format properly.
Thanks, but, I've tried googling it and looking in my books and I can't find any information on what an output tag is :(. What do they look like?
Buran added output tag. Click on Help/Rules --> BBCode for how to use
Oh, I thought you meant to type into script on python to get the block words to show up properly, sorry about that.
You need to show working snippet of code for us to see what's missing.
# Game Over - Version 2
# Demonstrates the use of quotes in string

print("Program 'Game Over' 2.0")

print("Same", "message", "as before")

print("Just",
      "a bit",
      "bigger")

print("Here", end=" ")
print("it is...")

[output]print(
                """
                 _____       ___       ___  ___   _____
                /  ___|     /   |     /   |/   | |  ___|
                | |        / /| |    / /|   /| | | |___
                | |  _    / ___ |   / / |__/ | | |  ___|
                | |_| |  / /  | |  / /       | | | |___
                \_____/ /_/   |_| /_/        |_| |_____|
                 _____   _     _   _____   _____
                /  _  \ | |   / / |  ___| |  _  \
                | | | | | |  / /  | |___  | |_| |
                | | | | | | / /   |  ___| |  _  /
                | |_| | | |/ /    | |___  | | \ \
                \_____/ |___/     |_____| |_|  \_\

                """
              )
[/output]

input("\n\Press the enter key to exit.")
# Game Over - Version 2
# Demonstrates the use of quotes in string

print("Program 'Game Over' 2.0")

print("Same", "message", "as before")

print("Just",
      "a bit",
      "bigger")

print("Here", end=" ")
print("it is...")

print(
                r"""
                 _____       ___       ___  ___   _____
                /  ___|     /   |     /   |/   | |  ___|
                | |        / /| |    / /|   /| | | |___
                | |  _    / ___ |   / / |__/ | | |  ___|
                | |_| |  / /  | |  / /       | | | |___
                \_____/ /_/   |_| /_/        |_| |_____|
                 _____   _     _   _____   _____
                /  _  \ | |   / / |  ___| |  _  \
                | | | | | |  / /  | |___  | |_| |
                | | | | | | / /   |  ___| |  _  /
                | |_| | | |/ /    | |___  | | \ \
                \_____/ |___/     |_____| |_|  \_\

                """
              )

input("\n\Press the enter key to exit.")
Look at r""" raw string added in your print function.
This fix your escape character problem with output.
Output:
Program 'Game Over' 2.0 Same message as before Just a bit bigger Here it is... _____ ___ ___ ___ _____ / ___| / | / |/ | | ___| | | / /| | / /| /| | | |___ | | _ / ___ | / / |__/ | | | ___| | |_| | / / | | / / | | | |___ \_____/ /_/ |_| /_/ |_| |_____| _____ _ _ _____ _____ / _ \ | | / / | ___| | _ \ | | | | | | / / | |___ | |_| | | | | | | | / / | ___| | _ / | |_| | | |/ / | |___ | | \ \ \_____/ |___/ |_____| |_| \_\
Worked like a charm, thank you very much.