Friday, February 22, 2019

How to let the user input as many lines of input as they want until they input the "stop" word in Python?

Say that I'm asking the user to input lines from a book or whatever. I don't know how many lines they will decide to input though. How would you let them input as many lines as they want until they input a secret word, "blueblue" for example. That's the code i've got so far.



while (blueblue == false):
line1 = input()



Help would be much appreciated.



Hey, after using Owen's code i'm having a problem with reading and outputing some info. I'd like to ask it here instead of opening another question. Here's my code now:



lines = []
current_line = input()
while current_line != "blueblue":
lines.append(current_line)
current_line = input()
print (lines)

ints_list = []
for line_ in lines:
for letter in line:
if (letter == "0","1","2","3","4","5","6","7","8","9"):
print ("hueheuheuehheuue")


Now Say that user input is :



1 hello my name

is cmput 3.4


It will just print "huehueheuheu" the number of characters there are in the while input.
I've tried the number without brackets and still deson't work, i've even tried "or".
Please help.

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...