took me a few months to figure this out (jeez im dumb) but by changing the less than sign to greater than in top 5, the list can be sorted in descending order :)

This commit is contained in:
K 2023-12-10 16:47:58 +05:30
parent 4b2cfdc89b
commit 6db1cebae8
Signed by: notkshitij
GPG Key ID: C5B8BC7530F8F43F

View File

@ -30,9 +30,9 @@ def bubble():
def top5():
for i in range(len(marks)):
for j in range(0, len(marks)-i-1):
if marks[j]>marks[j+1]:
if marks[j]<marks[j+1]:
marks[j], marks[j+1] = marks[j+1], marks[j]
print("Top 5 marks using bubble sorting:\t", marks[len(marks):len(marks)-6:-1]) # Requires 6 elements in the list.
print("Top 5 marks using bubble sorting:\t", marks[0:5])
def choose_optn():