はじめに
paiza様のpython問題集から、単語のカウント問題を解きました
問題
スペースで区切られた英単語列が与えられます。
英単語列に含まれる英単語の出現回数を出現した順番に出力してください。
実装したソースコード
array1 = input().split(' ')
array2 = []
for x in array1:
if x not in array2:
array2.append(x)
for y in array2:
count = 0
for z in array1:
if z == y:
count += 1
print(y + " " + str(count))
実行した結果
最後に
この問題は実は段階別にヒント問題を解いて最終的にこの問題を解く流れです。