I'm very new to python and am trying to figure out a way to access dictionaries from an input and then add values of similar keys in the dictionaries, then print the resulting value from adding those similar key values. The bad code I have now is:
p = {
"charge" : 1,
"energy": 938,
"spin": 1/2,
}
n = {
"charge" : 0,
"energy": 940,
"spin": 1/2,
}
e = {
"charge": -1,
"energy": 0.511,
"spin": 1/2,
}
x = input("First particle:")
y = input("Second particle:")
tcharge = x.get("charge")+y.get("charge")
tenergy = x.get("energy")+y.get("energy")
tspin = x.get("spin")+y.get("spin")
print(tcharge)
print(tenergy)
print(tspin)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…