When someone writes a string or a letter, I want the code make them go back, and the code to print "must be a number and bigger than 0 and less than 100", but what actually happens is the code closing. Is there by any chance a fix for this?
import timedef main():num1 = input("your t76ely\n")num2 = input("your num2\n")school = input("your school\n")num1 = float(num1)num2 = float(num2)school = float(school)if num1 > 100:print("must be a number and bigger than 0 and less than 100")while True:time.sleep(1)main()elif num1 < 0:print("must be a number and bigger than 0 and less than 100")while True:time.sleep(1)main()if num2 > 100:print("must be a number and bigger than 0 and less than 100")while True:time.sleep(1)main()elif num2 < 0:print("must be a number and bigger than 0 and less than 100")while True:time.sleep(1)main()if school > 100:print("must be a number and bigger than 0 and less than 100")while True:time.sleep(1)main()elif school < 0:print("must be a number and bigger than 0 and less than 100")while True:time.sleep(1)main()else:r = (40 % 100 * float(num1)) + (30 % 100 * float(num2)) + (30 % 100 * float(school))r = r / 100print(r)print('\nnum1 :', {num1}, '\nnum2 :', {num2}, "\nschool :", {school})while True:main()if input("\nWant To continue ? Y/N\n").upper().strip() != "Y":break
It's showing me this when I try to type for example my name "trais" or a letter or a "string"
Traceback (most recent call last):File "D:\Python Projects\your mark\mark calculator.py", line 51, in <module>main()File "D:\Python Projects\your mark\mark calculator.py", line 9, in mainnum1 = float(num1)
ValueError: could not convert string to float: 'trais'