Professional Documents
Culture Documents
CYB 130 Week 5 Python LAB 6.25 Filter and Sort A List
CYB 130 Week 5 Python LAB 6.25 Filter and Sort A List
lst = []
if int(x)>0:
lst.append(int(x))
lst.sort()
for x in lst:
print(x,end=" ")
print()
Code 2
integers = input().split()
# non-negative integers.
non_neg_int=[]
# integers list.
if num>= 0:
non_neg_int.append(num)
# sort() function.
non_neg_int.sort()
# non-negative integers.
for i in non_neg_int:
print(i,end=' ')
Code 3
our_input = [int(our_input) for our_input in input("Enter value Seperated By Space: ").split()]#get
all that input from user
new_input=[]#take new empty input list
for i in our_input:
if(i>0):
new_input.append(i)
new_input.sort()#sort asendering here
for i in new_input:
print(i,end = ' ')
code 4
#separated by space.
num_values = input()
#Split those numbers through spaces, store the numbers
if int(num) >=0]
list_values.sort()