[Tutor] Beginners question

Michael Langdon michael.langdon01 at gmail.com
Mon Mar 30 17:11:22 EDT 2020


Hi there,


I have been tasked to use a while loop to repeatedly ask the user to enter
a word.

If the word is not 'quit', then add it to the list of words collected so
far, in lower case. Then ask for the next word and so on.

If they enter 'quit', do not add this word to the list, but print the list
of words collected so far and exit the program.

My input.
a = input("Enter a word: ")
sentence = sentence , a
while a != ("quit"):
sentence = sentence , a
a = input("Enter a word: ")
print(sentence)

My output.
Enter a word: orange
((), 'orange')
Enter a word: apple
(((), 'orange'), 'orange')
Enter a word: quit
((((), 'orange'), 'orange'), 'apple')


Can you help me with this?

Regards,

Michael


More information about the Tutor mailing list