Spocoman

09. Fruit or Vegetable

Dec 20th, 2021 (edited)
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. product = input()
  2.  
  3. if product == 'banana' or product == 'apple' \
  4.         or product == 'kiwi' or product == 'cherry' or product == 'lemon' or product == 'grapes':
  5.     print('fruit')
  6. elif product == 'tomato' or product == 'cucumber' or product == 'pepper' or product == 'carrot':
  7.     print('vegetable')
  8. else:
  9.     print('unknown')
  10.  
  11.  
  12. Фундаменталс решение:
  13.  
  14. product = input()
  15. fruit = ['banana', 'apple', 'kiwi', 'cherry', 'lemon', 'grapes']
  16. vegetable = ['tomato', 'cucumber', 'pepper', 'carrot']
  17.  
  18. if fruit.__contains__(product):
  19.     print('fruit')
  20. elif vegetable.__contains__(product):
  21.     print('vegetable')
  22. else:
  23.     print('unknown')
  24.  
  25.  
Add Comment
Please, Sign In to add comment