Help 1/13


#1

names = ["Adam","Alex","Mariah","Martine","Columbus"]
for names in[Adam, Alex, Mariah, Martine, Columbus]
print names
I have that but it says syntax error line 2


#2

@adam_jenions,

The syntax error is a result of your not ending the second line with a colon. But, for it to work properly, you also need to use the variable, names, to which you assigned the list in the first line, rather than to attempt to repeat the items in the list in that line. The second line should be:

for name in names:

Then the new variable, name will represent each name within the loop. To output each name, change the third line to this, and make sure that line is indented, so that it is part of the for loop:

print name

#3

[quote="geomaticmashups, post:2, topic:1222"]
print name
[


#4

this worked for me:

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

i believe the loop is copying the values in names , one at a time into variable x and then prints x.


#5

sorry about the large font above.


#6

try this code it worked for me:
names = ["Adam","Alex","Mariah","Martine","Columbus"]

for name in names:
print name