0

I am making a hangman game, which gets the hangman shape from a list. For some reason though, because each image is in a multiline string, somehow it loses formatting so that one line goes on the same as another.

Here's the code:

    '''

     ___________.._______
    | .__________))______|
    | | / /      ||
    | |/ /       ||
    | | /        ||.-''.
    | |/         |/  _  \
    | |          ||  `/,| #this line!
    | |          (\\`_.'
    | |          -`--'
    | |          |   |
    | |          |   |
    | |          |   |
    | |          | _ |
    | |          
    | |          
    | |          
    | |          
    | |         
    """"""""""""""""""""""""|
    |"|"""""""\ \       '"|"|
    | |        \ \        | |
    : :         \ \       : :  
    . .          `'       . .'''

Obviously, where it say's '#this line!', that's the one that moves up. I can provide the rest of the list if required.

Thanks! :)

codemonkeyz
  • 35
  • 1
  • 4

2 Answers2

3

Try escaping the \ (backslash).

Clarification: the line before the line that moves up ends in a '\', this character has special meaning, if you escape it by adding another '\' it will work properly, so change it to '\\'.

Blubber
  • 2,214
  • 1
  • 17
  • 26
0

The other thing you can do is to define your string as a raw string:

a = r'''

...

'''

Note the 'r' character before the string definition

sherve
  • 300
  • 2
  • 10