including ascii art in python

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

       ***************                                                
       *             *                                                
       *             *                                                
       *             *                                                
       *           ....                                               
       *           .  ..                                              
       *          ..   .                                              
       *          ..   .                                              
       *           .....                                              
       *             .                                                
       *       .......                                                
       *                                                              
       *                                                              
       *                                                              
       *                                                              
       *                                                              
       *                                                              
       *                                                              
       *                                                              
       *                                                              
       *                                                              
       *                                                              

`

Upvotes: 2

Views: 21973

Answers (2)

Ned Batchelder
Ned Batchelder

Reputation: 375484

"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]

Upvotes: 1

Martijn Pieters
Martijn Pieters

Reputation: 1121406

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

Upvotes: 10

Related Questions