Nov-01-2020, 11:47 AM
Hello!
So I tried to search about this, but can't find an explanation regarding the output.
I just started learning Python. Thanks in advance for any help!
So I tried to search about this, but can't find an explanation regarding the output.
a = [3, 1, -2] print(a[a[-1])
Output:1
I initially thought that this would return an error, but it ran fine. I also thought that it would just reference the last element which is -2 thinking that -1 in the print() is referring to the index.I just started learning Python. Thanks in advance for any help!