[Tutor] iterating over less than a full list

Sander Sweers sander.sweers at gmail.com
Sat Sep 4 19:29:23 CEST 2010


On 4 September 2010 19:25, Sander Sweers <sander.sweers at gmail.com> wrote:
> for x in some_stuff:
>    if x <= 10:
>        print x
>    else:
>        break

Oops, corrected version...

count = 0
for x in some_stuff:
    if count < 10:
        print x
        count +=1
    else:
        break

Greets
Sander


More information about the Tutor mailing list