how to make this situation return this result?

Michael Torrie torriem at gmail.com
Sat Jul 1 13:44:45 EDT 2017


On 07/01/2017 02:55 AM, Ho Yeung Lee wrote:
> expect result as this first case
> 
> ii = 0
> jj = 0
> for ii in range(0,3):
>     for jj in range(0,3):
>         if ii < jj:
>             print (ii, jj)
> 
> 
> but below is different
> as sometimes the situation is not range(0,3), but it a a list of tuple 
> 
> iiii = 0
> jjjj = 0
> for ii in range(0,3):
>     for jj in range(0,3):
>         if iiii < jjjj:
>             print (iiii, jjjj)
>         jjjj = jjjj + 1
>     iiii = iiii + 1
> 
> how to make this situation return result like the first case?

I hope your production code uses brief but descriptive variable names
and also uses comments (either there was a big sale on i's and j's or
your other letters are broken), unlike the code you just posted!  Might
help you figure out your logic and also let others more quickly grasp
what you're thing to do.





More information about the Python-list mailing list