I am learning to code in Python. I am creating a program that will perform unit conversions, however I have been stuck on this error for a good while:
NameError: name 'ini' is not defined
Here is the code:
a = ("Distance") b = ("Time") c = ("Volume") d = ("Temp") e = ("Weight") def conversion_type(first): if first == ("Distance"): ini = input("How great a distance am I converting?\n") elif first == ("Time"): ini = input("How much time am I converting?\n") elif first == ("Volume"): ini = input("How great a volume am I converting?\n") elif first == ("Temp"): ini = input("How many degrees am I converting?\n") elif first == ("Weight"): ini = input("How much weight am I converting?\n") else: print("That not was an afformentioned dimension you dolt.") def variable_type_converter(ini): ini = float(ini) print ("\n Welcome to the Convert-O-Matic\n==============================\n") print ("I support the following dimensions:\n") print ("%s, %s, %s, %s, and %s," % (a,b,c,d,e)) first = input("What kind of conversion would you like to do?\n") conversion_type(first) variable_type_converter(ini) print("==========================================")
{}button.