Евгений InterChat
прохожу практикум от яндекса, кто сможет объяснить че не так делаю((
Кек я бы вообще вот так сделал:
def print_friends_count(friends_count, name=''):
if len(str(friends_count)) >= 2 and str(friends_count).isdigit() and ('2' in str(friends_count)[-1] or '3' in str(friends_count)[-1] or '4' in str(friends_count)[-1]):
text= str(friends_count) + ' ' + 'друга.'
print(f'\n{name} у тебя {text}')
elif len(str(friends_count)) == 1 and str(friends_count).isdigit() and ('2' in str(friends_count)[-1] or '3' in str(friends_count)[-1] or '4' in str(friends_count)[-1]):
text= str(friends_count) + ' ' + 'друга.'
print(f'\n{name} у тебя {text}')
elif str(friends_count)[0] == '1' and str(friends_count).isdigit() \
and (friends_count % 11 != 0 ):
text= str(friends_count) + ' ' + 'друг.'
print(f'\n{name} у тебя {text}')
elif len(str(friends_count)) >= 2 and friends_count % 11 != 0 and str(friends_count).isdigit():
text= str(friends_count) + ' ' + 'друзей.' (или всё-таки друг)
print(f'\n{name} у тебя {text}')
else:
text=str(friends_count) + ' ' + 'друзей.'
print(f'\n{name} у тебя {text}')
print_friends_count(23, 'Мария')
print_friends_count(22, 'Мария')
print_friends_count(2, 'Мария')
print_friends_count(6, 'Мария')
print_friends_count(3, 'Александр')
print_friends_count(7, 'Александр')
print_friends_count(8, 'Александр')
print_friends_count(11, 'Александр')
print_friends_count(5, 'Андрей')
print_friends_count(69, 'Павел')
print_friends_count(1, 'Сергей')
print_friends_count(31, 'Сергей')
print_friends_count(41, 'Сергей')
print_friends_count(26721, 'Сергей')