0

I'm trying too use a song lyric as an user input and after every verse comes a new line. Python recognizes a new line as an "ENTER" and will just deals with the first verse. How can I input the hole lyrics in a single input with the linebreaks?

user_input = input('Input song lyrics: ')

input: We're no strangers to love You know the rules and so do I A full commitment's what I'm thinking of You wouldn't get this from any other guy

print (user_input)

output: We're no strangers to love

2 Answers2

1

Base on this link, you can not get multi-line input easily and a solution can be as below:

print('Input song lyrics: ')

x =  input() 
inp = []
while x != '':  
    inp.append(x) 
    x = input()
print(inp)

Drawback would be user should enter empty line to end it

Hassan
  • 118
  • 6
0

When writing into input instead of hitting enter write \n. It is a sign that python understands as newline.

Example:

"We're no strangers to love \nYou know the rules and so do I \nA full commitment's what I'm thinking of \nYou wouldn't get this from any other guy"

Don't worry about no space between \n and next character, python will interpret \n as a sigh to jump to new line and then start with the next word. You can even remove space before \n as that would eliminate the space on the end of every line or in your case verse.