Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Put the marks [72, 85, 64, 90, 58] in order, first with the smallest first, then with the biggest first.
sort() changes the list. reverse=True puts the biggest first.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
marks.sort() gives [58, 64, 72, 85, 90].marks.sort(reverse=True) gives [90, 85, 72, 64, 58].Note. sort() changes the list itself. If you want to keep the first list, use sorted(marks), which gives a new sorted list.
Log in to join the discussion.
Loading…