malaclypse2 at gmail.com
Fri Jun 8 21:51:49 CEST 2007
Brian, I'm including the list back in on this reply, so that more than
just me can see your message and potentially help out.
On 6/8/07, Brain Murphy <brianomorchoe at yahoo.co.uk> wrote:
> this is what i have so far.
> x= 100
> while x > 0:
> print x
> the problem is that since it is a tuple I can not use that last part, x =
> how can I put this in a loop?
> were it goes through the whole number, as in 100/2=50 50/2 25 ect.
> but also keeping the remiander?
Since divmod() returns a tuple, you need to unpack it. For example:
>>> q, r = divmod(10, 3)
>>> print q
>>> print r
If you want to store all the remainders as you go, maybe you could
build up a list of remainders by starting with an empty list and
append() the values to the list as you go through the loop.
More information about the Python-list