[Tutor] range() fractional increment
Alan Gauld
alan.gauld at btinternet.com
Tue Mar 31 23:21:24 CEST 2009
"james carnell" <jimcarnell at yahoo.com> wrote
> example:
> x0000 row = 25 : col = 10
> x0000 row = 26 : col = 10.3
> x0000 row = 27 : col = 10.6
> 0x000 row = 28 : col = 11
> for col in range(10,12, 0.3): #<- Crash Bang doesn't work 0.3 = zero =
> infinite loop?
If you know the limits (rather than their being variables) you can do
for n in range(100,120,3)
n = n/10
But if you have variable range limits then a generator
or while loop are your best bets I think.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/l2p/
More information about the Tutor
mailing list