# odd

4 messages
Open this post in threaded view
|

## odd

 I ran thisfor x in range(5,10):    print xand OP was 56789why is that? shouldn't it print t678910? _______________________________________________ Tutor maillist  -  [hidden email] http://mail.python.org/mailman/listinfo/tutor
Open this post in threaded view
|

## Re: odd

 > 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.comwesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com_______________________________________________ Tutor maillist  -  [hidden email] http://mail.python.org/mailman/listinfo/tutor
 In reply to this post by elis aeris from Guido's tutorial: The given end point is never part of the generated list; `range(10)` generates a list of 10 values, the legal indices for items of a sequence of length 10. It is possible to let the range start at another number, or to specify a different increment (even negative; sometimes this is called the `step')On 7/19/07, elis aeris <[hidden email]> wrote:I ran thisfor x in range(5,10):    print x and OP was 56789why is that? shouldn't it print t678910? _______________________________________________Tutor maillist  -  [hidden email] http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist  -  [hidden email] http://mail.python.org/mailman/listinfo/tutor