Answer the question
In order to leave comments, you need to log in
Yandex.Workshop 9. Database query prototype Where is the error?
Add a process_query() function call to runner() with the argument 'Where are all my friends?'.
Run and make sure Anfisa sees the request. Let her not understand what to do in response.
DATABASE = {
'Серёга': 'Омск',
'Соня': 'Москва',
'Миша': 'Москва',
'Дима': 'Челябинск',
'Алина': 'Красноярск',
'Егор': 'Пермь',
'Коля': 'Красноярск'
}
def format_friends(friends_count):
if friends_count == 1:
return 'У тебя 1 друг'
elif 2 <= friends_count <= 4:
return 'У тебя ' + str(friends_count) + ' друга'
elif friends_count >= 5:
return 'У тебя ' + str(friends_count) + ' друзей'
def process_query(query):
if query == 'Сколько у меня друзей?':
count = len(DATABASE)
return format_friends(count)
elif query == 'Кто все мои друзья?':
friends_string = ', '.join(DATABASE)
return 'Твои друзья: ' + friends_string
else:
return '<неизвестный запрос>'
def runner():
print('Привет, я Анфиса!')
print(process_query('Сколько у меня друзей?'))
print(process_query('Кто все мои друзья?'))
def process_query('Где все мои друзья?'):
runner()
process_query('Где все мои друзья?')
Answer the question
In order to leave comments, you need to log in
The mistake is that you don't understand what a function call is, what arguments are, and you don't read the assignment well.
Add a process_query () function call to runner() with the argument 'Where are all my friends?'.
Deciphering: Add a process_query('Where are all my friends?') call to the runner() function declaration.
And you there kolbasil yourself some horrors.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question