[Tutor] odd
wesley chun
wescpy at gmail.com
Thu Jul 19 03:00:51 CEST 2007
> for x in range(5,10):
> print x
>
> and OP was
>
> 5
> 6
> 7
> 8
> 9
>
> why is that? shouldn't it print
>
> t
> 6
> 7
> 8
> 9
> 10?
no. the (well, one) syntax for range() is (start, stop) where it
counts starting from 'start' up to but not including 'stop'. if
you're familiar with C/C++ (or PHP or Java), it's similar to the
counting loop, "for (int i=5; i < 10; i++)", which counts 5, 6, 7, 8,
9.
hope this helps!
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Core Python Programming", Prentice Hall, (c)2007,2001
http://corepython.com
wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
More information about the Tutor
mailing list