Advertisement
CR7CR7

Digit

Feb 24th, 2022
819
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def zero ():
  2.     return "zero"
  3. def one ():
  4.     return "one"
  5. def two ():
  6.     return "two"
  7. def three ():
  8.     return "three"
  9. def four ():
  10.     return "four"
  11. def five ():
  12.     return "five"
  13. def six ():
  14.     return "six"
  15. def seven ():
  16.     return "seven"
  17. def eight ():
  18.     return "eight"
  19. def nine ():
  20.     return "nine"
  21. def default ():
  22.     return("not a digit")
  23.  
  24. switcher = {
  25.     1: one,
  26.     2: two,
  27.     3: three,
  28.     4: four,
  29.     5: five,
  30.     6: six,
  31.     7: seven,
  32.     8: eight,
  33.     9: nine
  34.     }
  35.  
  36. def switch(digit):
  37.     return switcher.get(digit, default)()
  38. print(switch(-0.1))
  39. print(switch(1))
  40. print(switch(9))
  41. print(switch(-9))
  42. print(switch("kek"))
  43.  
  44.  
Advertisement
RAW Paste Data Copied
Advertisement