Advertisement
Spocoman

02. Drink Something

Jan 13th, 2022
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. age = int(input())
  2. drink = ''
  3. if age <= 14:
  4.     drink = 'toddy'
  5. elif age <= 18:
  6.     drink = 'coke'
  7. elif age <= 21:
  8.     drink = 'beer'
  9. elif age > 21:
  10.     drink = 'whisky'
  11. print(f'drink {drink}')
  12.  
  13.  
  14. Решение с колекция:
  15.  
  16. age = int(input())
  17. drink = {age <= 14: 'toddy', 14 < age <= 18: 'coke', 18 < age <= 21: 'beer', age > 21: 'whisky'}
  18. print(f'drink {drink[True]}')
  19.  
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement