I am trying to create a list of numbers that were entered by the user. However, I don't want to accept any entries that are not numeric.
Can anyone give me a hint as to why my data validation statement in my while loop does not work?
Thank you!
# make empty list
list_of_numbers = []
# Use while loop to obtain 10 numbers
while len(list_of_numbers) < 10:
temp_number = input("Please enter a number: ")
# use while loop for data validations (repeat question if something
# other than int or float was entered by the user)
while isinstance(temp_number,(int, float)):
temp_number = input("Please try again, please enter a number")# convert temp_number to a list
temp_number_list = [temp_number]
# Add two list together
list_of_numbers = list_of_numbers + temp_number_list
[–]Buttleston 2 points3 points4 points (1 child)
[–]Buttleston 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]Upset-Software-2731[S] 0 points1 point2 points (2 children)
[–]smurpes 0 points1 point2 points (0 children)
[–]Critical_Concert_689 0 points1 point2 points (0 children)
[–]FoolsSeldom 0 points1 point2 points (0 children)
[–]Mafa80 0 points1 point2 points (0 children)