-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOddOrEven.py
More file actions
26 lines (21 loc) · 768 Bytes
/
OddOrEven.py
File metadata and controls
26 lines (21 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
keepChecking = True
exitWord = {"X","QUIT"}
print("This programs checks if number is odd or even")
print("You may enter 'X', 'Quit' to exit any time")
print('\n')
while keepChecking:
enterdNum = input ("Please enter any number : ")
#One mthod to check if set contains a word
if(exitWord.__contains__(enterdNum.upper())):
break
#using in keyword to check same
if(enterdNum.upper() in exitWord):
break
try:
enteredVal = int(enterdNum)
if(enteredVal % 2 == 0):
print("Entered value " + enterdNum + " is EVEN number" )
else:
print("Entered value " + enterdNum + " is ODD number" )
except(ValueError):
print("Entered value was not a valid number. Please try again.")