Q. What is the output of the following code?
Code:
[ (a,b) for a in range(3) for b in range(a) ]
β
Correct Answer: (A)
[(1,0),(2,0),(2,1)]
Explanation: It’s a nested loop. The output of the first “for” loop will be the value of the next loop.