Why is this "else statement" not working?
Instructions on how to use the code: 1. The real code has options for celsius to fahr, fahr to cels, cels to kelv, ETC., for simplicity I limit the code provided to Cels to Fahr. 2. Input like this "x-degree/100 c to f". "34.141512 c to f" 3. Program checks to 1) round the answer to two decimal places, 2) if it is a whole number it removes decimal point from printed integer. 3) it is SUPPOSED to check input for an "s". If "s" exist in input it should print an EXACT decimal. e.g. "94 c to f s" should print "202.20000002", but it doesn't. import re x = input("Degree c to f: ").lower() y = x if re.sub('[1234567890. ]', '', x) == "ctof": x = re.sub('[to cfks]', '', x) r = (9 / 5 * float(x) + 32) if r % 1 == 0: print(int(r)) # If it is a whole number it will remove the decimal point. elif r % 1 != 0: print(round(r, 2)) # rounded to two decimal places. else: x = re.sub("[1234567890. ctokf]", "", x) # this is designed so if 's' is in the input the program returns an EXACT answer if x == "s": print(float(r)) I have been working on this code for too long, so long that I dug myself into figuring out why it won't work ( I rechecked and rewrote everything ten times).....I need help.