如何在Python列表中找到元素[1]的正索引

2024-09-29 01:20:07 发布

您现在位置:Python中文网/ 问答频道 /正文

如何找到myList[-1]的正索引?
这是我想要的一个例子:

输入:

myList = [1, 2, 3, 4, 3]
# Please keep in mind that the list can have multiple values that are the same

myIndex = # Find out the positive index of myList[-1] and store in myIndex variable
print(myIndex)

期望输出:

4

Tags: theinthathavemultiplecanarelist