2019-12-20 14:17:56 Python

13-3.py

Copy Copied! Full
print("勇者はエンカウントしたモンスターを見てみた。") monsters ={} with open("encount.txt","r",encoding="utf_8") as file: line =file.readlines() for i in line: h =i.rstrip("\n") b =h.split(" ") monsters[b[0]]=b[1] for name,counts in monsters.items(): print("{}{}".format(name,counts)) maxcounts =0 maxname ="" for name,counts in monsters.items(): if int(maxcounts)<int(counts): maxname =name maxcounts =counts print("最もエンカウント数が多いのは{}で{}回だった!".format(maxname,maxcounts))
13-3.py