Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ファイル経由でインポートされた整数のリストがあります
xy = [50, 2, 34, 6, 4, 3, 1, 5, 2]
私はPythonを知っています:最小の整数を見つける
ただし、最小の数字を見つけるだけでなく、その位置をどのように印刷できるのでしょうか?
メソッドを使用するだけlist.indexです:
list.index
print xy.index(min(xy)) # 6
ただし、最小値が繰り返されると、最初に出現したインデックスのみが取得されます。
indices = [i for i, x in enumerate(xy) if x == min(xy)] # Indices of all min occurrences