[Tutor] Geometric sequence

Peter O'Doherty abjadmailinglist at gmail.com
Wed Oct 30 18:08:11 CET 2013


Hi List,

I know a geometric sequence can be produced by:

series = [2**x for x in range(7)]

But I would like to curtail the sequence before the last element excedes 
a certain value. Is there a better way of doing it that the following:

for x in range(20):
     series_element = 2**x
     print series_element
     if series_element > 60:
         break
print series

Many thanks,
Peter


More information about the Tutor mailing list