chemlist = np.array(["carbon dioxide", "co2",
"carbon monoxide", "co",
"ethane", "c2h6",
"methane", "ch4",
"nitrogen", "n2",
"oxygen", "o2",
"water", "h2o (liquid)",
"water vapour", "h2o (gas)"])
print(chemlist)
chemical = input("Enter name or the chemical formula of your compound:\n")
chemical = chemical.lower()
print(chemical)
for i in range(len(chemlist)):
if chemical == chemlist[i]:
break
else:
print("Invalid chemical name. Please input one from the list below:\n")
print(chemlist)
chemical = input("Enter name or the chemical formula of your compound again:\n")
temperature = 0
temperature = float(input("Enter your temperature in degrees Kelvin:\n"))
if temperature <= 273.15 or temperature >= 673.15:
temperature = float(input('Temperature is not in range. Enter your temperature in degrees Kelvin again:\n'))
else:
break
Hello,
I have been trying to use this code as a test to find whether the user inputs a valid chemical species. However, when i run the code, it returns invalid for whatever i input even if it is the correct element from the array. What is wrong?
I have changed the way i defined the array from surrounding with single quotation marks to double but that also did not work.