IT45200

Untitled

Apr 2nd, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. def get_ordinal(n):
  2.  
  3.     my_dict = {1:'first', 2:'second', 3:'third', 4:'fourth', 5:'fifth',6:'sixth', 7:'seventh',8:'eighth',9:'ninth',10:'tenth', 11:'eleventh', 12:'twelfth' }
  4.  
  5.     if isinstance(n,int):
  6.         if n in my_dict.keys():
  7.             return my_dict.get(n)  
  8.     else:
  9.         return ''
  10.  
  11. print(get_ordinal(1))
Advertisement
Add Comment
Please, Sign In to add comment