sle7en
sle7en

Reputation: 41

coding raw_input prompt into multiple lines...?

newbie here. I got this raw_input prompt inside a loop so it is indented;

userInput = raw_input('Enter n to deal a new hand, r to replay the last\
hand, or e to end game: ')

when I run this I get 2 tabs of space (indentation) between "last" and "hand". Is there a way to get rid of this gap?

Thanks a lot in advance.

Upvotes: 1

Views: 824

Answers (1)

falsetru
falsetru

Reputation: 369064

You can use string literal concatenation:

userInput = raw_input(
    'Enter n to deal a new hand, r to replay the last '
    'hand, or e to end game: ')

Multiple adjacent string literals (delimited by whitespace), possibly using different quoting conventions, are allowed, and their meaning is the same as their concatenation. Thus, "hello" 'world' is equivalent to "helloworld". This feature can be used to reduce the number of backslashes needed, to split long strings conveniently across long lines, or even to add comments to parts of strings

Upvotes: 1

Related Questions