Re: How can I find the remainder when dividing 2 integers

2011-01-12 Thread Rohan Pai
Try using dividend % divisor, this will return the remainder Rohan Pai -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I find the remainder when dividing 2 integers

2006-03-01 Thread George Sakkis
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(

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread Andrea Griffini
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

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread Steven D'Aprano
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

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread Kent Johnson
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

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread Diez B. Roggisch
[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

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread silverburgh . meryl
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

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread Diez B. Roggisch
[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] >

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread silverburgh . meryl
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

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread David
[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

Re: How can I find the remainder when dividing 2 integers

2006-02-26 Thread Diez B. Roggisch
[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

How can I find the remainder when dividing 2 integers

2006-02-26 Thread silverburgh . meryl
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