Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions

Question

2. Describe how technology can impact intercultural interaction.

Answered: 1 week ago

Question

7. Define cultural space.

Answered: 1 week ago