I need to verification for the following code and also, alternative ways to do.
1. Check whether it is a whole number
2. Number is not numeric
Rather than catching as an exception, I would like to know how to check this with a an if condition as in above 1.
Thanks for helps
1. Check whether it is a whole number
Code:
if round(number) != number:
raise TypeError("Number is not a whole number")
2. Number is not numeric
Code:
try:
total = total + number
except ValueError:
raise TypeError("Number is not numeric")
Rather than catching as an exception, I would like to know how to check this with a an if condition as in above 1.
Thanks for helps