I want to get user input for multiple times and store the input data together in a string until input "quit" to quit from input. I think a for loop can work but I don't know how to do it.
while True:
user_input = raw_input("Enter something:")
if user_input == "quit":
break
Try this:
input_string = ''
while 1:
input = raw_input('Add to string: ')
if input == 'quit': break
input_string += input
while True:
input = raw_input('Prompt')
print input
if (input == 'quit'):
break;
来源:https://stackoverflow.com/questions/12608654/how-to-get-user-input-repeatly-until-i-want-to-quit