Advertisement
simeonshopov

Color Selection

Dec 5th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. def print_blue():
  2.     print('You chose blue!\r\n')
  3.  
  4. def print_red():
  5.     print('You chose red!\r\n')
  6.  
  7. def print_orange():
  8.     print('You chose orange!\r\n')
  9.  
  10. def print_yellow():
  11.     print('You chose yellow!\r\n')
  12.  
  13.  
  14. color_select = {
  15.     0: print_blue,
  16.     1: print_red,
  17.     2: print_orange,
  18.     3: print_yellow
  19. }
  20.  
  21. selection = 0
  22.  
  23. while (selection != 4):
  24.     print('0. Blue')
  25.     print('1. Red')
  26.     print('2. Orange')
  27.     print('3. Yellow')
  28.     print('4. Quit')
  29.    
  30.     selection = int(input('Select a color option: '))
  31.    
  32.     if selection >= 0 and selection < 4:
  33.         color_select[selection]()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement