It seems odd to me that there are three tests to see if user input is digits - isdecimal, isdigit, isnumeric, but nothing to test for a float unless you use a try - except. Or did I miss something? Anyway, I tried a try - except, but I don't see why my output is all integer when I only convert to integer if it passes the is_integer test:
user_values = [] while True: user_input = input("Give me a number: ") if user_input.lower() == 'done': break try: user_input = float(user_input) if user_input.is_integer: user_input = int(user_input) user_values.append(user_input) except Exception as err: print("You entered {0}, which is not a valid number: error - {1}".format(user_input, err)) continue print("Your entered numbers were {0}".format(user_values)) #only integers print, even when I entered some floats -- Jim If you only had one hour left to live, would you spend it on Facebook, Twitter, or Google Plus? _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor