Answer the question
In order to leave comments, you need to log in
Where is the error in the program?
The program should accept the number of names as input, the names themselves and display the names that match the rule, but only one name is accepted as input
Code:
def make_list(number):
names = []
for item in range(number):
names.append(input('Введите имя с заглавной буквы'))
return (names)
number = int(input('Сколько имен надо ввести?'))
names = make_list(number)
for name in names:
if name[0] == 'А':
print('Имя', name, 'Начинается с буквы А')
Answer the question
In order to leave comments, you need to log in
The most interesting thing is that the code works fine if it is formatted of course.
def get_names(num_items):
name_list = list()
for item in range(num_items):
name_list.append(input('Введите имя с заглавной буквы'))
return name_list
def get_quantity():
return int(input('Сколько имен надо ввести?'))
if __name__ == '__main__':
for name in get_names(get_quantity()):
if name.startswith('А'):
print('Имя', name, 'Начинается с буквы А')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question