[Tutor] Doubt in list comprehension
vinod bhaskaran
bhaskaran.vinod at gmail.com
Fri Feb 23 06:26:03 EST 2018
Hi All,
I am a beginner programmer and i wrote a small program (as per a assignment
i saw) as below:
newlist = []
for a in range(2,5):
for b in range (0,3):
newlist.append([a])
a = a + 1
print(newlist)
it gives the expected output as below:
[[2], [3], [4], [3], [4], [5], [4], [5], [6]]
but when i try list comprehension i am not able to get it correct....can
someone please suggest where the (a=a+1) should be placed in a list
comprehension
Thanks,
Vinod Bhaskaran
More information about the Tutor
mailing list