Write a program that gets a list of integers from input, and outputs non-negative integers in ascending orde
Write a
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.
My code:
int_list =input()
int_list = int_list.strip()
int_list = int_list.split()
num_list = []
for i in range(0, len(int_list)):
num_list.append(int(int_list[i]))
num_list.sort()
i = 0
while i <= len(num_list):
if num_list[i] >= 0:
print(num_list[i], end=' ')
i = i + 1
Output: We couldn’t run your program to completion. Could be a temporary system issue – please try again. Could be your program never finished, due to an infinite loop, infinite recursion, waiting for input, or other possibilities.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images