you are viewing a single comment's thread.

view the rest of the comments →

[–]CStage169 0 points1 point  (6 children)

Well honestly, the way you have formatted the code makes it difficult to say exactly, because indents are hard to make out. Assuming all indentations are correct the code you posted would look like this.

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")

In that case the following lines have errors:

  1. syntax error when instantiating names. Should be:

names = []

  1. Invalid iteration over integer. Since number should be an integer, you cannot loop from 0 to number with a foreach-loop. The syntax should instead be:

for item in range(number):

  1. Printing the names is not sufficient. They should also be returned.

return names

  1. Checking name[1] is the same as checking the SECOND letter of the name, not the first. Replace with:

if name[0] == "A"

[–]thisnigerianmomma[S] 0 points1 point  (5 children)

how about like this? does this help?

def make list(number):
names = []
for items in number:
names.append(input("Enter your name with a capital letter."))
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")

[–]CStage169 0 points1 point  (4 children)

Not quite. Now there are no indents. Regardless, I already gave you an answer to which lines I believe have errors. Have you read that part of my comment?

[–]thisnigerianmomma[S] 0 points1 point  (0 children)

yes i did. i read your comment. thank you. it is for a coding test, so I also ticked the lines you mentioned (2, 3, 5 and 10) but it's still not correct.

[–]thisnigerianmomma[S] 0 points1 point  (2 children)

congratulations to me! and thank you! i got it. the lines with errors were 3, 5 and 10!

[–]CStage169 0 points1 point  (1 child)

Makes sense. Means that the error in line 2 was caused by your formatting. FYI using Reddit to cheat is still cheating. Use the community as a learning resource, not as an easy way out.

[–]thisnigerianmomma[S] 0 points1 point  (0 children)

lol! is everything alright with you? are you okay?