AcWing 718. 实验 - Python3
原题链接
困难
作者:
KYCygni
,
2021-03-13 08:46:47
,
所有人可见
,
阅读 285
Python3 代码
n = int(input())
d = {"coneys" : 0, "rats" : 0, "frogs" : 0}
for i in range (n):
e = input().split()
if e[1] == "C":
d["coneys"] += int(e[0])
elif e[1] == "R":
d["rats"] += int(e[0])
elif e[1] == "F":
d["frogs"] += int(e[0])
total = 0
for x in d:
total += d[x]
print ("Total:", total, "animals")
print ("Total coneys:", d["coneys"])
print ("Total rats:", d["rats"])
print ("Total frogs:", d["frogs"])
print ("Percentage of coneys:",f'{d["coneys"] * 100/total:.2f}', "%")
print ("Percentage of rats:", f'{d["rats"] * 100/total:.2f}', "%")
print ("Percentage of frogs:", f'{d["frogs"] * 100/total:.2f}', "%")
“e = input().split()’‘
这个不是只输入了一个数吗???,怎么有阿e[1]和e[0]啊
新手求指教