Print with """ - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Print with """ (/thread-18763.html) |
Print with """ - Greatstillness - May-30-2019 Hi to everyone. I am absolute new in programming and Python. A started to learn it with one textbook, and one of the first exercises was printing multiple lines with triple quotes. And here the strange thing comes: the word "game" is printed normally, the word "over" is not printed normally. Why is it? How can I fix it? Thank you for your answers. For words see the picture: RE: Print with """ - ichabod801 - May-30-2019 For words, please copy and paste. Use BBCode tags to format code or output. RE: Print with """ - Greatstillness - May-31-2019 Here is the code: print("Program 'Game Over' 2.0") print(''' __________ _______ ____ _____ ___________ / | / | / | / | | | / _______| / _ | / |/ | | _______| | | / / | | / /| /| | | | | | / /__| | / /| / | | | |_____ | | ___ / ____ | / / |___/ | | | _____| | | | | / / | | / / | | | | | |___| | / / | | / / | | | |_______ \ / / / | | / / | | | | \_______/ /___/ |___| /___/ |___| |___________| _________ ___ ___ ___________ _______ / \ | | / / | | | \ / _ \ | | / / | _______| | |\ \ | / \ | | | / / | | | | \ \ | | | | | | / / | |_____ | |_/ / | | | | | | / / | _____| | / | | | | | | / / | | | |\ \ | \_/ | | |/ / | |_______ | | \ \ \ / | / | | | | \ \ \_________/ |______/ |___________| |___| \___\ ''')In this message the output seems to be correct (therefore I didn't put it here), but in Spider and in the console it is not. Why? RE: Print with """ - Yoriz - May-31-2019 In Python strings, the backslash "\" is a special character, also called the "escape" character. It is used in representing certain whitespace characters: "\t" is a tab, "\n" is a newline, and "\r" is a carriage return. Put an r in front of the string to make it a raw string it will then treat the "\" as normal "\". print("Program 'Game Over' 2.0") print(r''' __________ _______ ____ _____ ___________ / | / | / | / | | | / _______| / _ | / |/ | | _______| | | / / | | / /| /| | | | | | / /__| | / /| / | | | |_____ | | ___ / ____ | / / |___/ | | | _____| | | | | / / | | / / | | | | | |___| | / / | | / / | | | |_______ \ / / / | | / / | | | | \_______/ /___/ |___| /___/ |___| |___________| _________ ___ ___ ___________ _______ / \ | | / / | | | \ / _ \ | | / / | _______| | |\ \ | / \ | | | / / | | | | \ \ | | | | | | / / | |_____ | |_/ / | | | | | | / / | _____| | / | | | | | | / / | | | |\ \ | \_/ | | |/ / | |_______ | | \ \ \ / | / | | | | \ \ \_________/ |______/ |___________| |___| \___\ ''')Another option is to use double "\\" print("Program 'Game Over' 2.0") print(''' __________ _______ ____ _____ ___________ / | / | / | / | | | / _______| / _ | / |/ | | _______| | | / / | | / /| /| | | | | | / /__| | / /| / | | | |_____ | | ___ / ____ | / / |___/ | | | _____| | | | | / / | | / / | | | | | |___| | / / | | / / | | | |_______ \ / / / | | / / | | | | \_______/ /___/ |___| /___/ |___| |___________| _________ ___ ___ ___________ _______ / \ | | / / | | | \\ / _ \ | | / / | _______| | |\ \\ | / \ | | | / / | | | | \ \\ | | | | | | / / | |_____ | |_/ / | | | | | | / / | _____| | / | | | | | | / / | | | |\ \\ | \_/ | | |/ / | |_______ | | \ \\ \ / | / | | | | \ \\ \_________/ |______/ |___________| |___| \___\\ ''')An extra blank space in place of the doubled "\" will also work RE: Print with """ - Greatstillness - May-31-2019 Thank you very much, I understood the problem. |