Is it possible to get two nested for statements followed by a nested
if/else statement all into a single list comprehension ie. the equivalent
of the below:
for i in xrange(1,20):
for j in xrange(1,10):
if j6:
j=int(8+str(j))
else:
j=int(9+str(j))
Jignesh Sutar wrote:
Is it possible to get two nested for statements followed by a nested
if/else statement all into a single list comprehension ie. the equivalent
of the below:
for i in xrange(1,20):
for j in xrange(1,10):
if j6:
j=int(8+str(j))
else:
Peter Otten wrote:
[locals()] does not capture
the loop vars of genexps (all pythons) and listcomps (python3).
Sorry, I was totally wrong on that one.
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
On 03/17/2014 11:22 AM, Jignesh Sutar wrote:
Is it possible to get two nested for statements followed by a nested
if/else statement all into a single list comprehension ie. the equivalent
of the below:
for i in xrange(1,20):
for j in xrange(1,10):
if j6:
Is it possible to get two nested for statements followed by a nested
if/else statement all into a single list comprehension ie. the equivalent
of the below:
for i in xrange(1,20):
for j in xrange(1,10):
if j6:
j=int(8+str(j))
else:
j=int(9+str(j))
python executes the first for and its condititions then the next for.
What i'm saying is that you should first deal with one as nested block codes
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
Thanks Peter/Denis. I wasn't aware of genexp. I see how you have adapted
the code to make it work, I'll adapt the same in my program. Good point
about duplicating j , Denis, I guess I was happy to override the outer j as
it was intermediate.
On 17 March 2014 12:36, spir denis.s...@gmail.com