How can I find the remainder when dividing 2 integers

silverburgh.meryl at gmail.com silverburgh.meryl at gmail.com
Sun Feb 26 15:28:07 EST 2006


okay, I try you suggestion, and re-write my code like this:
colors = ["#ff0000", "#00FF00", "#0000FF"]
colorIndex = 0

def getText(nodelist):


             for str in strings:

                     print colors[colorIndex  % colors.length]
                     colorIndex += 1

but i get this error:
   print colors[colorIndex  % colors.length]
UnboundLocalError: local variable 'colorIndex' referenced before
assignment




More information about the Python-list mailing list