text = "" while text != "quit": text = raw_input("Please enter a chemical formula (or 'quit' to exit): ") if text == "quit": print "...exiting program" elif text == "H2O": print "Water" elif text == "NH3": print "Ammonia" elif text == "CH3": print "Methane" else: print "Unknown compound"