You are receiving your input incorrectly. Try this:

a = []
for i in range(n):
    a.append(int(input()))

Or, as a list comprehension:

a = [int(input()) for i in range(n)]

Also, if you want to test if a number can be split into two even numbers, try x % 4 instead of x % 2.

Answer from iz_ on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-take-multiple-inputs-using-loop-in-python
How to Take Multiple Inputs Using Loop in Python - GeeksforGeeks
July 23, 2025 - It then prompts the user to enter a value and uses a `while` loop to continuously take inputs until the user types 'exit'. Each entered value is appended to the `inputs_list`. Finally, the program prints the collected inputs after the loop exits.
🌐
EyeHunts
tutorial.eyehunts.com › home › how to take multiple inputs in python using while loop | example code
How to take multiple inputs in Python using while loop
August 4, 2023 - If you use an infinite loop then break it if the input is 0. values = [] while True: val = int(input("Enter an integer, 0 for Exit: ")) if val == 0: break values.append(val) print(values) ... Enter an integer, 0 for Exit: 1 Enter an integer, 0 for Exit: 2 Enter an integer, 0 for Exit: 0 [1, 2] Comment if you have any doubts or suggestions on this Python multiple input code.
Discussions

Python-Take multiple inputs using for loop and print multiple outputs through if condition - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
How to store multiple user inputs into a string during a while loop?
how can I get all 4 responses of animals to store in a variable You can store the animal names in a list (declaring it like this: animal_list = [], and add to it like so: animal_list.append(animal_name) The method .append() on lists just adds another value to a list. You can do this indefinitely, growing your list. To access all the animals in the list, you can do the following: for animal in animal_list: print(animal) More on reddit.com
🌐 r/learnpython
7
3
August 22, 2018
How to take more inputs from a user at the same time in Python?
The split() method will generate a list. number_list = input("Please input multiple integers separated by commas: ").split(',') Note that this will generate a list of strings. If you want to convert them to integers for later use, you'll need another step. More on reddit.com
🌐 r/learnpython
5
1
February 16, 2023
Python using while loop with multiple inputs and choices - Stack Overflow
I'm new to python and having some issues with a task. I need to write a code with example output: Calculator Give the first number: 50 Give the second number: 5 (1) + (2) - (3) * (4) / (5)Change nu... More on stackoverflow.com
🌐 stackoverflow.com
February 4, 2022
🌐
Brainly
brainly.com › computers and technology › high school › how can you take multiple inputs in python using a while loop?
[FREE] How can you take multiple inputs in Python using a while loop? - brainly.com
November 28, 2023 - To take multiple inputs in Python using a while loop, you can use the input() function within the loop to continuously prompt the user for input.
🌐
Amanxai
amanxai.com › home › all articles › multiple inputs with python using while loop
Multiple Inputs with Python using While Loop | Aman Kharwal
June 25, 2021 - The code leverages the Python while loop, Python’s most general loop statement. The built-in input function is used here for general console input, it prints its optional argument string as a prompt, and returns the response entered by the user as a string.
🌐
Reddit
reddit.com › r/learnpython › how to store multiple user inputs into a string during a while loop?
r/learnpython on Reddit: How to store multiple user inputs into a string during a while loop?
August 22, 2018 -

So I am trying a practice problem with the following guidelines:

"Use while to get the user input, animal_name, of 4 animals use a counter, num_animals, in the while loop condition

append the names to a string variable, all_animals

User can exit early by typing "exit" (check if animal_name is "exit" and break)

when the loop finishes, print the names of all_animals"

My current code is:

num_animals = 0

while num_animals <4:

    animal_name = input("Name an animal").lower()

    num_animals += 1

    all_animals = animal_name

    if animal_name == "exit":

    break

print(all_animals)

Basically my question is, how can I get all 4 responses of animals to store in a variable so I can print that variable and have all 4 responses show up?

🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-take-multiple-inputs-using-loop-in-python
How to Take Multiple Inputs Using Loop in Python - GeeksforGeeks
July 23, 2025 - It then prompts the user to enter a value and uses a `while` loop to continuously take inputs until the user types 'exit'. Each entered value is appended to the `inputs_list`. Finally, the program prints the collected inputs after the loop exits.
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › python-for-loop-user-input
Using a For or While Loop to take user input in Python | bobbyhadz
On each iteration, the user gets prompted for input. Note that we can't use a try/except statement for validation in a list comprehension. ... Use a while loop to iterate until a condition is met.
🌐
Stack Overflow
stackoverflow.com › questions › 70992134 › python-using-while-loop-with-multiple-inputs-and-choices
Python using while loop with multiple inputs and choices - Stack Overflow
February 4, 2022 - import operator from time import sleep class Calculator: CHANGE_NUMBER = 5 QUIT = 6 math_operations = { 1: operator.add, 2: operator.sub, 3: operator.mul, 4: operator.truediv, } options = { 1: "+", 2: "-", 3: "*", 4: "/", 5: "Change Number", 6: "Quit" } def __init__(self): self.n1 = None self.n2 = None print("Calculator") def run(self): while True: operation = self.operation() if not operation: break # We go out of the while loop def operation(self): if self.n1 is None or self.n2 is None: self.get_numbers() else: print(f"\n Current numbers: {self.n1}, {self.n2}") return self.procces_operation(
🌐
Tutorial Reference
tutorialreference.com › python › examples › faq › python-how-to-use-for-loop-to-take-user-input
How to Take User Input with Loops in Python | Tutorial Reference
while True:: This creates an infinite loop that we'll break out of only when valid input is received. This is a very common and useful pattern. try...except ValueError:: This handles the potential ValueError that occurs if the user enters something that can't be converted to an integer (e.g., ...
🌐
GitHub
github.com › devika-be › Multiple-Inputs-with-Python-using-While-Loop
GitHub - devika-be/Multiple-Inputs-with-Python-using-While-Loop: Project - Multiple Inputs with Python using While Loop · GitHub
The code leverages the Python while loop, Python’s most general loop statement. The built-in input function is used here for general console input, it prints its optional argument string as a prompt, and returns the response entered by the user as a string.
Author: devika-be
🌐
Tutorial Reference
tutorialreference.com › python › examples › faq › python-how-to-take-multiple-inputs-using-loop
How to Take Multiple Inputs Using a Loop in Python | Tutorial Reference
For complex scenarios that require validation or error handling inside the loop, a standard for loop is more readable. When you don't know in advance how many inputs the user will provide, use a while loop that continues until the user enters a special sentinel value (like "done" or "exit"):
🌐
Sololearn
sololearn.com › en › Discuss › 2954949 › how-to-take-input-from-user-multiple-times-using-while-loop
How to take input from user multiple times using while loop?? | Sololearn: Learn to code for FREE!
The corrected code! Also, you need to understand how SoloLearn input / submit a value works. It differs from a classic IDE. Use forum search to learn more on that matter. #1. Why did you used free() ? #2. Why did you used a while loop with a nested for loop? #3. What do you try to accomplish: ...
🌐
Javatpoint
javatpoint.com › how-to-take-multiple-input-from-user-in-python
How to take Multiple Input from User in Python - Javatpoint
How to take Multiple Input from User in Python with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
🌐
GeeksforGeeks
geeksforgeeks.org › taking-multiple-inputs-from-user-in-python
Taking multiple inputs from user in Python - GeeksforGeeks
December 3, 2024 - We then use a loop to take inputs one by one, appending each input to a list. After the loop finishes, we print the collected items. This approach gives the user the flexibility to enter as many items as needed.
🌐
Scaler
scaler.com › home › topics › how to take multiple input in python?
How to Take Multiple Input in Python? - Scaler Topics
March 30, 2024 - To avoid the repetitive use of the inbuilt functions from Python which eventually makes the program heavy we have three functions in Python split(), list comprehension, and map() function in python to help us resolve the problem where we are required to give multiple input in Python. Choose from our industry-leading programs designed for career success ... While writing code for programs, we may come across scenarios where we may need to provide multiple input in Python to make our programs easier to understand and reduce the load on the file memory.
🌐
Streamlit
discuss.streamlit.io › using streamlit
I want to take multiple inputs in a for loop - Using Streamlit - Streamlit
May 10, 2020 - labels=[] for i in range(len(labels): ** st.write(labels[i])** ** final=st.text_input(“final”,key=0)** ** title=st.text_input(“title”,key=1)** ** emotion=st.text_input(“title”,key=2)** ** labels.append(final,title,emotions)** So the code is just executing the for loop and not waiting for the user to input the value.