Having difficulty creating error handling when inputting an integer
dvdQuant = input("Enter quantity of DVD: ")
how can I get python to return a print "Error Message" if an integer is not entered instead of
Enter quantity of DVD: gyfj
Traceback (most recent call last):
File "I:/Python/CourseworkVer3. py", line 203, in <module>
addDvd(catalogu e)
File "I:/Python/CourseworkVer3. py", line 129, in addDvd
dvdQuant = input("Enter quantity of DVD: ")
File "<string>", line 1, in <module>
NameError: name 'gyfj' is not defined
I have the input put into a dictionary so I can multiply with another integer in another function, if I change input to raw_input then when I try and multiply it doesn't recognise the input as an integer
Ihope this isn't too vague and any help would be appreciated
dvdQuant = input("Enter quantity of DVD: ")
how can I get python to return a print "Error Message" if an integer is not entered instead of
Enter quantity of DVD: gyfj
Traceback (most recent call last):
File "I:/Python/CourseworkVer3. py", line 203, in <module>
addDvd(catalogu e)
File "I:/Python/CourseworkVer3. py", line 129, in addDvd
dvdQuant = input("Enter quantity of DVD: ")
File "<string>", line 1, in <module>
NameError: name 'gyfj' is not defined
I have the input put into a dictionary so I can multiply with another integer in another function, if I change input to raw_input then when I try and multiply it doesn't recognise the input as an integer
Ihope this isn't too vague and any help would be appreciated
Comment