BeFOR We Begin i don't get what's wrong


#1

So, call me stupid, but i can't get what is wrong in my code.
Anyway, the instructions are - "Use a for loop to print out all of the elements in the list names"
At first i did this:

names = ["Adam","Alex","Mariah","Martine","Columbus"]
for name in names:
    print names
#that prints the whole list five times, in square brackets

But i get an error: "Oops, try again. It looks like your code did not print "Adam"."

So, then I typed another code:

names = ["Adam","Alex","Mariah","Martine","Columbus"]
for first_name in names:
    print names
for second_name in names:
    print names
for third_name in names:
    print names
for fourth_name in names:
    print names
for fifth_name in names:
    print names
#that prints the whole list five times, in square brackets (same result at from previous code)

And again, I get the same error: "Oops, try again. It looks like your code did not print "Adam"."


#2

for name in names:
    print names

Instead of saying print names type in print name because now the instant variable name stores the list names. :slight_smile:


#3

Thank you! It was really helpful. Now I got it


#4

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.