Is it possible to let a user input any number of words one per line using the input function?

I was wondering is it possible to let a user enter any number of words one per line using the input function. So for example, let’s say I have the following prompt:

Enter any number of words, one per line, or a blank line to stop:

and the output is something like this:

hello

my

name

is

dave

What would the code for this look like?

>Solution :

simply :

while True:
    x = input()
    if x == '':
        break

Leave a Reply