12311k

Untitled

Mar 10th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. FRIENDS = ['Серёга', 'Соня', 'Дима', 'Алина', 'Егор']
  2.  
  3.  
  4. def show_count_friends(count_friends):
  5. if count_friends == 1:
  6. return 'У тебя 1 друг'
  7. elif 2 <= count_friends <= 4:
  8. return 'У тебя ' + str(count_friends) + ' друга'
  9. elif count_friends >= 5:
  10. return 'У тебя ' + str(count_friends) + ' друзей'
  11.  
  12.  
  13. def process_query(query):
  14. if query == 'Сколько у меня друзей?':
  15. count = len(FRIENDS)
  16. return show_count_friends(count)
  17. elif query == 'Кто все мои друзья?':
  18. friends_string = ', '.join(FRIENDS)
  19. return 'Твои друзья: ' + friends_string
  20. else:
  21. return '<неизвестный запрос>'
  22.  
  23.  
  24. # Внимание! Это те самые вызовы, которые не надо трогать
  25. print(process_query('Сколько у меня друзей?'))
  26. print(process_query('Кто все мои друзья?'))
  27. print(process_query('Как меня зовут?'))
Add Comment
Please, Sign In to add comment