subject

Filter and sort a list Write a program that gets a list of integers from input, and outputs non-negative integers in ascending order (lowest to highest).

Ex: If the input is:

10 -7 4 39 -6 12 2
the output is:

2 4 10 12 39
For coding simplicity, follow every output value by a space. Do not end with newline.

I have tried and come up with a TypeError on line 7. I have tried everything to fix it. A hint or help would be appreciated.

This is my code.
# asking for user input
nums = input()
lst = nums. split() # user input splits
# starting of a new list
new_list = ([])
for i in lst: # for loop to see if i in lst is true
if int(i) > 0: # if loop to see it integer is greater than 0
new_list. append(int(i)) # adding integers to the end
new_list. sort() # sorting new list in order, lowest to largest
for x in new_list: # seeing if x is true in the new list
print(x, end=' ') # printing new list in new order

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:30
If an improvement creates no significant change in a product’s performance, then it is a(n) ? a0 design improvement. (there are no answer choices)
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings starting from index 0. for each match, add one point to userscore. upon a mismatch, exit the loop using a break statement. assume simonpattern and userpattern are always the same length. ex: the following patterns yield a userscore of 4: simonpattern: rrgbryybgy userpattern: rrgbbrybgy
Answers: 2
question
Computers and Technology, 24.06.2019 02:10
Consider the usual algorithm to convert an infix expression to a postfix expression. suppose that you have read 10 input characters during a conversion and that the stack now contains these symbols: (5 points) | | | + | | ( | bottom |_*_| now, suppose that you read and process the 11th symbol of the input. draw the stack for the case where the 11th symbol is
Answers: 2
question
Computers and Technology, 24.06.2019 12:30
Why does the pc send out a broadcast arp prior
Answers: 1
You know the right answer?
Filter and sort a list Write a program that gets a list of integers from input, and outputs non-neg...
Questions
question
Mathematics, 04.12.2020 20:20
question
Advanced Placement (AP), 04.12.2020 20:20
question
Mathematics, 04.12.2020 20:20
question
English, 04.12.2020 20:20
Questions on the website: 13722362