Skip to content

Instantly share code, notes, and snippets.

@TheMuellenator
Last active September 3, 2023 11:36
Show Gist options
  • Save TheMuellenator/d98dacca633022999f5368e693f02b5d to your computer and use it in GitHub Desktop.
Save TheMuellenator/d98dacca633022999f5368e693f02b5d to your computer and use it in GitHub Desktop.
Python Lists Coding Exercise Solution
def top_three(scores):
scores = scores
top_scores = []
# Solution
scores.sort()
list_size = len(scores)
top_scores = [scores[list_size-1], scores[list_size-2], scores[list_size-3]]
# Leave this line alone
return top_scores
@Dannysesi
Copy link

scores.sort(reverse=True)
top_scores = [scores[0], scores[1], scores[2]]

@katalystkat
Copy link

scores.sort(reverse=True)
for i in range(3):
top_scores.append(scores[i])

@Ayush0901
Copy link

scores.sort(reverse=True)
for i in range (0,3):
a = scores[i]
top_scores.append(a)

@MrXTheAnon
Copy link

scores.sort()
scores.reverse()
top_scores = [scores[i] for i in range(len(scores)) if i < 3]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment