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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!