including ascii art in python
20,860
Solution 1
Use the '''
or """
triple-quoted string literal:
longstring = """\
You can use multiple lines
and newlines
are preserved
"""
I used a \
newline escape after the opening tripple-quote to avoid having to put the first line right after the opening quotes. The string thus starts at You
(no newline before it):
>>> longstring = """\
... You can use multiple lines
... and newlines
... are preserved
... """
>>> print longstring
You can use multiple lines
and newlines
are preserved
Solution 2
"like they can have multi-line comments": There are no multi-line comments, only multi-line strings, and of course you can print them:
wrong_art[2] = """
***************
* *
* *
* *
* ....
* . ..
* .. .
* .. .
* .....
* .
* .......
*
*
*
*
*
*
*
*
*
*
*
"""
print wrong_art[num_wrong]
Comments
-
בנימן הגלילי almost 2 years
I am making a hangman program, how can I include my art in the python without typing print on every line is there a multi-line print like they have multi-line comments? I don't mind importing all of the pictures from a text file, can't figure this out from the documentation, thanks for your help.
def visual(): if count = 1: ## shows the hanging ascii art
`
*************** * * * * * * * * * * * * * * * * * * * * * * * * * ***********************
one wrong
*************** * * * * * * * .... * . .. * .. . * .. . * ..... * * * * * * * * * * * * *
two wrong
*************** * * * * * * * .... * . .. * .. . * .. . * ..... * . * ....... * * * * * * * * * * *
`