Skip to content

Instantly share code, notes, and snippets.

@tsal
Last active October 21, 2019 22:54
Show Gist options
  • Save tsal/d11387c50daf2fdcaf86ebbcfdee1253 to your computer and use it in GitHub Desktop.
Save tsal/d11387c50daf2fdcaf86ebbcfdee1253 to your computer and use it in GitHub Desktop.
ordinals example
def switch_suffix(digit):
switch = {
1: "st",
2: "nd",
3: "rd",
}
return switch.get(digit % 10, "th")
ordinals = [i+1 for i in range(10)]
for num in ordinals:
print(f"{num}{switch_suffix(num)}")
@tsal
Copy link
Author

tsal commented Oct 21, 2019

... and fixed a bug.

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