i am trying to relearn the basics and i have this code,
try:
n1 = float(input('enter a number: '))
except ValueError:
print('invalid input!')
n1 = float(input('enter a number: '))
try:
n2 = float(input('enter a second number: '))
except ValueError:
print('invalid input!')
n2 = float(input('enter a second number: '))
this is part of a bigger program and this is the section designed to detect if the valid input (number) is entered, it is meant to repeat until a number is entered but it only loops once before an error occurs 'cant convert string to float'. i have tried to put a while loop around it but i cant get it to work. if anyone can help with a solution i would greatly appreciate it. thank you
i tried to add a while loop to this section of the program to make it loop until a number was entered but it still only loops once before an error message.