如何通过输入显示输入数字的位置?

Bor*_*LOC 3 python list python-3.x

我有一个列表,一旦我对它进行排序以找到"最大值",我需要显示输入该数字的位置.

知道怎么做吗?

我制作了这个代码来接收和排序列表,但我不知道如何接收"数据"的初始位置.


liste = []

while len(liste) != 5:
    liste.append (int(input("enter number :\n")))

listeSorted = sorted(liste)
print("the biggest number is : ", listeSorted[-1]) 
Run Code Online (Sandbox Code Playgroud)

Pri*_*usa 6

不要通过对列表进行排序来查找列表的最大值,而是使用max函数:

largest_val = max(list)
Run Code Online (Sandbox Code Playgroud)

要查找列表中第一次出现的值,请使用该.index方法.

position = list.index(largest_val)
Run Code Online (Sandbox Code Playgroud)