【发布时间】:2019-08-08 14:43:53
【问题描述】:
这是我的程序,
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
【问题讨论】:
-
让我们明确一点:您想在一个数组中找到所有最高的数字,将它们放入另一个数组中,打印它们并打印它们的索引?
标签: python arrays python-3.x python-2.7