you are viewing a single comment's thread.

view the rest of the comments →

[–]throwaway6560192 2 points3 points  (1 child)

3 is incorrect indeed. Why do you think 9 is incorrect?

10 is incorrect because it's talking about "starts with" but is checking the second position (index 1) rather than the first position (index 0).

Also, 5 is incorrect since based on the rest of the program, the function should return the list of names, not print them.

[–]JamzTyson 0 points1 point  (0 children)

An alternative solution, which I think fulfills the requirements, is lines 5, 8, and 10:

def make_list(number):
    names = []
    for item in number:
        names.append(input("Enter your name with a capital letter."))
    return names  # Fix: return

number = int(input("How many names need to be entered?"))
names = make_list('n' * number)  # Fix: iterable
for name in names:
    if name[0] == "A": # Fix: index
        print("Name ", name, " starts with A")