import sys time = float(input("Length of time (as a number): ")) if time < 0: print('Invalid time. Time must be a positive number.') sys.exit() orig_time = time from_unit = input('Unit of time (second, minute, hour, day): ').lower() #convert from_unit into seconds if from_unit == 'minute': time *= 60 elif from_unit == 'hour': time *= 3600 elif from_unit == 'day': time *= 86400 else: print('Invalid unit of time') sys.exit() to_unit = input('Convert to (second, minute, hour, day): ') #convert from seconds into to_unit if to_unit == 'minute': time /= 60 elif to_unit == 'hour': time /= 3600 elif to_unit == 'day': time /= 86400 else: print('Invalid unit of time') sys.exit() time = round(time, 4) #format(time, '.4f') print(orig_time, from_unit, '=', time, to_unit)