Daniel Heitel
Daniel Heitel

Reputation: 11

Print function Backslash disappears Python 3

The Backslashes in the Game over disappear how can I keep them visible?

__author__ = 'daniel'
# Game Over 2.0
# demonstrates the use of quotes in strings

print ("Program 'Game Over' 2.0")

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

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

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

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

         _____   _     _   _____   _____
        /  _  \ | |   / / |  ___| |  _  \
        | | | | | |  / /  | |__   | |_| |
        | | | | | | / /   |  __|  |  _  /
        | |_| | | |/ /    | |___  | | \ \
        \_____/ |___/     |_____| |_|  \_\

        """
     )

input("\n\nPress the enter key to exit.")

Upvotes: 1

Views: 664

Answers (1)

Cory Kramer
Cory Kramer

Reputation: 117886

The '\' characters are being treated as escape characters. Use the r prefix to treat it as a raw string literal

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

         _____   _     _   _____   _____
        /  _  \ | |   / / |  ___| |  _  \
        | | | | | |  / /  | |__   | |_| |
        | | | | | | / /   |  __|  |  _  /
        | |_| | | |/ /    | |___  | | \ \
        \_____/ |___/     |_____| |_|  \_\

        """
     )

Upvotes: 2

Related Questions