Skip to content

Instantly share code, notes, and snippets.

@fatosmorina
Created November 14, 2021 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fatosmorina/408959d9a7921b6aae56736ebec10657 to your computer and use it in GitHub Desktop.
Save fatosmorina/408959d9a7921b6aae56736ebec10657 to your computer and use it in GitHub Desktop.
import heapq
scores = [51, 33, 64, 87, 91, 75, 15, 49, 33, 82]
print(heapq.nlargest(3, scores)) # [91, 87, 82]
print(heapq.nsmallest(5, scores)) # [15, 33, 33, 49, 51]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment