Python: For loop problem

Posted by Yasmin on Stack Overflow See other posts from Stack Overflow or by Yasmin
Published on 2010-03-11T16:26:50Z Indexed on 2010/03/11 17:34 UTC
Read the original article Hit count: 290

Filed under:
|
|

I have a simple for loop problem, when i run the code below it prints out series of 'blue green' sequences then a series of 'green' sequences. I want the output to be; if row[4] is equal to 1 to print blue else print green.

 for row in rows:
        for i in `row[4]`:
            if i ==`1`:
                print 'blue '
            else:
                print 'green '

Any help would be grateful

thanks

Yas

© Stack Overflow or respective owner

Related posts about python

Related posts about for