12311k

Untitled

Mar 3rd, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. def get_friends(request, user):
  2. user_friends = friends[user]
  3. friends_count = len(user_friends)
  4. if friends_count == 1:
  5. return HttpResponse(f'У пользователя {user} один друг: {user_friends[0]}.')
  6. elif 2 <= friends_count <= 4:
  7. friends_string = ', '.join(user_friends)
  8. return HttpResponse(f'У пользователя {user} {friends_count} друга: {friends_string}.')
  9. elif friends_count > 4:
  10. friends_string = ', '.join(user_friends)
  11. return HttpResponse(f'У пользователя {user} {friends_count} друзей: {friends_string}.')
  12. else:
  13. return HttpResponse(f'У пользователя {user} нет друзей :(')
Add Comment
Please, Sign In to add comment