Untitled
unknown
python
a year ago
1.0 kB
8
Indexable
#defining the function for checking the blue number conditions
def blueChecker(number):
try:
number = int(number)
if 100<number<400 and number%2 ==1:
return True
else:
print("Error: This is not a blue integer. Try again!!!")
return False
#except block throws an error and returns false which prints the
#error message in the While loop
except ValueError:
print("Error: This is not an integer. Try again!!!")
return False
#while loop for first int and checks the int in the checker function
while True:
num1 = input("Enter the 1st blue integer: ")
if blueChecker(num1):
print()
break
#same while loop for second int
while True:
num2 = input("Enter the 2nd blue integer: ")
if blueChecker(num2):
print()
break
#finally printing the equation
print("Display equation:")
print("{0} + {1} = {2}".format(num1, num2, int(num1) + int(num2)))
Editor is loading...
Leave a Comment