So I was doing my school work and one of the programming challenges I need to do is a periodic table challenge. I didn't think it would be that hard to program, but I encountered a problem that I am not able to resolve. It is not a syntax error and I have already spend hours on the internet going through guide on whether I am using the if statements correctly, but I was unable to identify the mistake. My code reads:
lithium = ("""Name: Lithium
Atmomic mass: 6.94
Group: Alkali Metals""")
sodium = ("""Name: Sodium
Atomic mass: 22.989769 u ± 2 × 10^-8 u
Group: Alkali Metals""")
potassium = ("""Name: Potassium
Atmoic mass: 39.0983 u ± 0.0001 u
Group: Alkali Metals""")
rubidium = ("""Name: Rubidium
Atomic mass: 85.4678 u ± 0.0003 u
Group: Alkali Metals""")
cesium = ("""Name: Ceasium
Atomic mass: 132.90545 u ± 2 × 10^-7 u
Group: Alkali Metals""")
francium = ("""Name: Francium
Atomic mass: 223 u
Group: Alkali Metals""")
################################################################################################################################################################
helium = ("""Name: Helium
Atomic Mass: 4.002602 u ± 0.000002 u
Group: Noble Gasses""")
neon = ("""Name: Neon
Atomic Mass: 20.1797 u ± 0.0006 u
Group: Noble Gasses""")
argon = ("""Name: Argon
Atomic Mass: 39.948 u ± 0.001 u
Group: Noble Gasses""")
krypton = ("""Name: Krypton
Atomic Mass: 83.798 u
Group: Noble Gasses""")
xenon = ("""Name: Xenon
Atomic Mass: 131.293 u ± 0.006 u
Group: Noble Gasses""")
radon = ("""Name: Radon
Atomic Mass: 222 u
Group: Noble Gasses""")
def noble():
print(helium)
print(" ")
print(neon)
print(" ")
print(argon)
print(" ")
print(krypton)
print(" ")
print(xenon)
print(" ")
print(radon)
def alkali():
print(lithium)
print(" ")
print(sodium)
print(" ")
print(potassium)
print(" ")
print(rubidium)
print(" ")
print(cesium)
print(" ")
print(francium)
print ("""Please choose the element you are looking for from the list below
Lithium
Sodium
Potassium
Rubidium
Caesium
Francium
Helium
Neon
Argon
Krypton
Xenon
Radon
Alternatively you can type in the name of one of these groups to get the data for first 6 elements in the group
Noble Gasses
Alkali Metals""")
userchoice = str(input())
if userchoice == "Helium" or "helium":
print(helium)
elif userchoice == "Neon" or "neon":
print(neon)
elif userchoice == "Argon" or "argon":
print(argon)
elif userchoice == "Krypton" or "krypton":
print(krypton)
elif userchoice == "Xenon" or "xenon":
print(xenon)
elif userchoice == "Radon" or "radon":
print(radon)
elif userchoice == "Lithium" or "lithium":
print(lithium)
elif userchoice == "Sodium" or "sodium":
print(sodium)
elif userchoice == "Potassium" or "potassium" or "Potasium" or "potasium":
print(potassium)
elif userchoice == "Rubidium" or "rubidium":
print(rubidium)
elif userchoice == "Caesium" or "caesium" or "Cesium" or "cesium":
print(cesium)
elif userchoice == "Francium" or "francium":
print(francium)
elif userchoice == "Noble Gasses" or "noble gasses" or "noble" or "gasses":
print(noble())
elif userchoice == "Alkali Metals" or "alkali metals" or "akali metals" or "Akali Metals":
print(alkali())
else:
print("Element not recognised")
Now my problem is that no matter what I put in for the userchoice variable the outcome is always printing the (helium) variable, what I mean by that that even if I put in "neon" it will still print helium even though helium variable is only supposed to be printed if userchoice variable contains the word "Helium" or "helium". It is is shown in the piece of code below:
userchoice = str("Neon")
if userchoice == "Helium" or "helium":
print(helium)
elif userchoice == "Neon" or "neon":
print(neon)
I wanted to know if someone would be so nice and help me to make it so that the program actually works, at this point just to clarify no matter the input, all the program outputs is the helium variable which reads:
helium = ("""Name: Helium
Atomic Mass: 4.002602 u ± 0.000002 u
Group: Noble Gasses""")