I am new to Python and I wonder what is wrong with this code, I searched for this,I guess in the end of the make_list function I have to return, and not print(). and in the end I have to write
if name[0]
and not if name[1]
, but what else is wrong with it?
Code:
def make_list(number):
names = []
for item in number:
names.append(input("Enter your name with a capital letter."))
print(names)
number = int(input("How many names need to be entered?"))
names = make_list(number)
for name in names:
if name [1] == 'A':
print("Name", name, "starts with A")
Compiler says:
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "<string>", line 3, in make_list
TypeError: 'int' object is not iterable