Skip to content

Python for loop user input | Example code

  • by

You can loop round for each input with for loop user input in Python.

Example asking user input with for loop in Python

Simple example code. First, get the number of loops then use create an empty list. Loops around for each input and Appends new input values.

loops = int(input("Amount of loops: "))

lis = []

for x in range(loops):
    lis.append(input("Input: "))

print(lis)

Output:

Python for loop user input

Do comment if you have any doubts or suggestions on this user input code.

Note: IDE: PyCharm 2021.3.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.