我试图在Python映射中为疾病添加症状,但我无法添加症状,因为它给出了一个错误。有没有一种方法可以做到这一点?我如何获取输入,然后使用用户输入的症状计算最接近的疾病
代码如下:
diseases = {'Coronavirus':'fever', 'dry cough','tiredness',
'Common Cold': 'cough', 'cold',
'Heart Attack': 'pain', 'pressure', 'squeezing'}
symptoms = input("Please type your symptoms (If there are multiple then separate them by a ',') (Note: type all in small letters): ")
if symptoms == 'fever, dry cough, tiredness':
print("Your disease is Coronavirus or cornavirus! Deadly Disease: Yes")
if symptoms == 'cough, cold':
print("Your disease is Common cold, Deadly Disease: No, but must consult a doctor if sever.")
这是一个字典,添加多个“症状”(在:)作为列表,因此介于[…]之间。使用以下代码:
把它列为清单
相关问题 更多 >
编程相关推荐