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
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to