looking for a neat solution to a nested loop problem

Larry Hudson orgnut at yahoo.com
Tue Aug 7 06:02:33 CEST 2012


On 08/06/2012 11:11 AM, Emile van Sebille wrote:
    <snip>
>
>       for i in range(N,N+100):
>           for j in range(M,M+100):
>               do_something(i % 100 ,j % 100)
>
> Emile

How about...

for i in range(100):
     for j in range(100):
         do_something((i + N) % 100, (j + M) % 100)

      -=- Larry -=-





More information about the Python-list mailing list