0

Print list question

Can you please explain how this code is working? a = [1,2,[3,4],6,5] print(a[a[2][1]]) The result is 5. I am not able to figure out how it's working. Thanks for your help.

21st Nov 2019, 8:35 AM
Stefan Färber
1 Antwort
+ 3
a[2] is [3,4], so a[2][1] is 4. So a[a[2][1]] = a[4] which is 5.
21st Nov 2019, 8:53 AM
Russ
Russ - avatar