BeFOR we begin


#1



https://www.codecademy.com/courses/python-beginner-en-IZ9Ra/0/1?curriculum_id=4f89dab3d788890003000096#


The error window says, "Oops. It looks like your code did not print 'Adam'."


I expected no error message.

names = ["Adam","Alex","Mariah","Martine","Columbus"]
for item in names:
    print names


#2

Hi this line

...
    print names

you should print item instead of names


#3

corrrect code is

names = ["Adam","Alex","Mariah","Martine","Columbus"]
for names in ["Adam","Alex","Mariah","Martine","Columbus"]:
print names


#4

That's a bit inefficient. Sure it's correct but what if names was longer than what is given? What if instead of just 5 names you're given 100? You wouldn't want to type out 100 names right? I suppose you could just copy and paste all that but it'd look a bit messy wouldn't it. In the for loop try replacing the list of names and use just names. It'd look a little like this...

names = ["Adam","Alex","Mariah","Martine","Columbus"]
for names in names:
print names

Give it a try! :smiley:


#5

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