+ 1
Sort inputs in ascending and descending order.
Say I wanna input as many numbers as I want, then sort them in ascending or descending order, how would I go about that? Also need help with the pseudocode of it if possible.
2 odpowiedzi
+ 3
Step 1 : Read integers using input() function ([int(i) for i in input().split()])
and assign it to a list
Step 2 : print your list to check the data using print()
Step 3 : use sorted() function to sort your list asc
Step 4 : print the sorted asc data
Step 5 : use sorted() function with attribute reverse=True to sort descending your list
Step 6 : print the sorted desc data
I hope it helps
+ 13
Have you tried something ? If you did, could you please post your attempt here ?