Question
3.8 LAB: Read values into a list Write a program that reads a list of integers into a list as long as the integers are
3.8 LAB: Read values into a list
Write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs the values of the list. (This is for CS119 with Python.)
Ex: If the input is:
10 5 3 21 2 -6
the output is:
[10, 5, 3, 21, 2]
You can assume that the list of integers will have at least 2 values.
Here is my code that is not working and yes I have tried several variations. I would appreciate help.
user_input = 1
user_numbers = []
while user_input>0:
user_input = int(input())
if user_input>0:
user_numbers.append(user_input)
print(user_numbers)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started