Before we being


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


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


so I have to put for names iterative


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.


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


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

You missed something??


colon of for loop header > :

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


hahahahahahahahahahh I missed :


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:


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