Python list negative index
2019-01-15 本文已影响5人
JaedenKil
"""
Negative index means count backwards.
Counting backwards begins with "-1", while counting forwards begins with "0"
"""
a = [1, 2, 3]
print(a[-1]) # 3
print(a[-2]) # 2
print(a[0]) # 1