How to take continuous input in Python | Example code

  • by

Use While loop with True condition expression to take continuous input in Python. And break the loop using if statement and break statement.

while True:


Example take continuous input in Python

Simple example code gets user input repeatedly until want to quit.

while True:

    user_input = input("Enter something: ")
    if user_input == "quit":



How to take continuous input in Python

And if you want to store input data use this code.

input_string = ''
while 1:
    inp = input('Add to a string: ')
    if inp == 'quit':
    input_string += inp



Add to a string: Hello
Add to a string: quit

Do comment if you have any doubts or suggestions on this Python input topic.

Note: IDE: PyCharm 2021.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.