How do i fix this error, whenever i enter data that should cause an exception more than once the program crashes. Here is my code and what it outputs, it should keep repeating until correct data is entered.
flag=False
while flag==False:
try:
number=int(input("Enter number of books: "))
except ValueError:
print("Please enter number of books as a positive whole number ")
number=int(input("Enter number of books: "))
else:
flag=True
Traceback (most recent call last):
File "C:\Users\Alex\OneDrive\Documents\ComputerScience\Intro2.py", line 5, in <module>
number=int(input("Enter number of books: "))
ValueError: invalid literal for int() with base 10: '3.3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Alex\OneDrive\Documents\ComputerScience\Intro2.py", line 8, in <module>
number=int(input("Enter number of books: "))
ValueError: invalid literal for int() with base 10: '3.4'