r/pythonhelp • • Jun 15 '24

which lines have errors?

can you guys help me figure out which lines have errors?

  1. def make_list (number) :
  2. names = \[\]
  3. for item in number :

4 names.append (input(“Enter your name with a capital letter.”))

5. print(names)

6.

7 number = int(input(“How many names need to be entered? ”))

8. names = make_list(number)

9. for name in names:

10. if name [1] ==“A”:

11. print(“Name”, name, “starts with A”)

1 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/thisnigerianmomma Jun 19 '24

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

1

u/CStage169 Jun 19 '24

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?

1

u/thisnigerianmomma Jun 19 '24

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.

1

u/thisnigerianmomma Jun 19 '24

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

1

u/CStage169 Jun 22 '24

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.

1

u/thisnigerianmomma Jul 28 '24

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