Advertisement
here2share

# n_suffix.py

Oct 31st, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. # n_suffix.py
  2.  
  3. def n_suffix(n):
  4.     if n:
  5.         print n % 10
  6.         suffix = "th"
  7.         if n < 4 or (n > 20 and n%10 in [1,2,3]):
  8.             suffix = ["st", "nd", "rd"][n%10-1]
  9.         return str(n)+suffix
  10. #
  11. for z in range(50): print n_suffix(z)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement