"""
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
"""
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
本文标题:Python list negative index
本文链接:https://www.haomeiwen.com/subject/savydqtx.html
网友评论