Skip to main content
 首页 » 编程设计

python之如何在数组中找到两个相似数字的索引

2025年05月04日20zengkefu

<分区>

这是我的程序,

item_no = [] 
max_no = 0 
for i in range(5): 
    input_no = int(input("Enter an item number: ")) 
    item_no.append(input_no) 
for i in item_no: 
    if no > max_no: 
       max_no = no 
high = item_no.index(max_no) 
print (item_no[high]) 

示例输入:5, 6, 7, 8, 8

示例输出:8

如何更改我的程序以输出数组中相同的最高数字以及如何在 (item_no) 中找到结果的索引?

预期输出:8, 8

item_no 中结果的预期索引:3, 4