[Tutor] Query regarding output

shubham goyal skgoyal721 at gmail.com
Wed Jun 28 22:14:07 EDT 2017


Hello all,

This Question is asked in some exam. i am not able to figure it out.

a = [0, 1, 2, 3]
for a[-1] in a:
    print(a[-1])

its giving output 0 1 2 2

it should be 3 3 3 3 as a[-1] belongs to 3.
can anyone help me figuring it out.

Thanks


More information about the Tutor mailing list