Before we being


#1

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


#2

The basic structure of for loop is this..

if we want to iterate over some iterative data type ..

for iterator in <iterative>:
    print iterator

iterator can be any variable name.
iterative can be any iterative data type : list,string,tuple etc


#3

so I have to put for names iterative


#4

Put anything other than names, even that will work but It will create confusion and finally over write our global list..

use this skeleton..

for <any variable name>  in names:
    print <any variable name>

<any variable name> can be anything like : i / j/ k or any valid variable name etc.


#5

it hard me to understand but I put
names = ["Adam","Alex","Mariah","Martine","Columbus"]
for x in names
print x


#6

You're close, just try to take a closer look at my syntax?

You missed something??

hint*

colon of for loop header > :

Also you have to indent (make spaces) your print x by 4 space bars inside the for loop body.


#7

hahahahahahahahahahh I missed :


#8

Yup!
Hey, I highly suggest to revise for loop again!!
In this section we are going to implement for loop a lot!
revision will give you a boost and you will able to deal most bugs you face! :slight_smile:


#9

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