配列に含まれる指定要素のカウント

  • Python3 の組み込み関数である count() 関数を用いることで、リストの中に含まれる値の数を求めることができます。

input()

a = list(map(int, input().split()))

print(a.count(1))