Try using dividend % divisor, this will return the remainder
Rohan Pai
--
http://mail.python.org/mailman/listinfo/python-list
Learn about ther itertools module, one of the most useful and elegant
modules in the standard library
(http://docs.python.org/lib/module-itertools.html):
import itertools as it
colors = ["#ff", "#00FF00", "#FF"]
words = "Itertools is a pretty neat module".split()
for word_color in it.izip(
Writing a while loop with ++x to increment the index was the first
mistake i made with python.
"++x" unfortunately is valid, it's not a single operator but a double
"unary plus"
Andrea
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 26 Feb 2006 21:58:30 +0100, Diez B. Roggisch wrote:
> [EMAIL PROTECTED] schrieb:
>> Can you please tell me what is the meaning of
>> UnboundLocalError: local variable 'colorIndex' referenced before
>> assignment
>>
>> in general?
>
> Well, pretty much of what it says: You tried to acce
Diez B. Roggisch wrote:
> [EMAIL PROTECTED] schrieb:
>
>> okay, I try you suggestion, and re-write my code like this:
>> colors = ["#ff", "#00FF00", "#FF"]
>> colorIndex = 0
>>
>> def getText(nodelist):
>>
>>
>> for str in strings:
>>
>> print colors[color
[EMAIL PROTECTED] schrieb:
> Can you please tell me what is the meaning of
> UnboundLocalError: local variable 'colorIndex' referenced before
> assignment
>
> in general?
Well, pretty much of what it says: You tried to access a variable without prior
assignment to it. Like this:
a = b**2 + c
Can you please tell me what is the meaning of
UnboundLocalError: local variable 'colorIndex' referenced before
assignment
in general?
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] schrieb:
> okay, I try you suggestion, and re-write my code like this:
> colors = ["#ff", "#00FF00", "#FF"]
> colorIndex = 0
>
> def getText(nodelist):
>
>
> for str in strings:
>
> print colors[colorIndex % colors.length]
>
okay, I try you suggestion, and re-write my code like this:
colors = ["#ff", "#00FF00", "#FF"]
colorIndex = 0
def getText(nodelist):
for str in strings:
print colors[colorIndex % colors.length]
colorIndex += 1
but i get this error
[EMAIL PROTECTED] wrote:
> I have a string array:
> colors = ["#ff", "#00FF00", "#FF"]
> colorIndex = 0;
>
> and I want to loop thru each element of colors
>
> for str in strings:
> print colors[colorIndex++ % colors.length]
>
>
> But i get an invalid syntax error when I execute the s
[EMAIL PROTECTED] schrieb:
> I have a string array:
> colors = ["#ff", "#00FF00", "#FF"]
> colorIndex = 0;
>
> and I want to loop thru each element of colors
>
> for str in strings:
> print colors[colorIndex++ % colors.length]
>
>
> But i get an invalid syntax error when I execute the
I have a string array:
colors = ["#ff", "#00FF00", "#FF"]
colorIndex = 0;
and I want to loop thru each element of colors
for str in strings:
print colors[colorIndex++ % colors.length]
But i get an invalid syntax error when I execute the script:
print colors[colorIndex++ % colors.l
12 matches
Mail list logo