I have to read unknown number of lines from stdin in python3. Is there a way to do this without any modules? One more question: How to denote end of input for multiple lines in python3?
Try something like this
a_lst = [] # Start with empty list
while True:
a_str = input('Enter item (empty str to exit): ')
if not a_str: # Exit on empty string.
break
a_lst.append(a_str)
print(a_lst)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With