-
Notifications
You must be signed in to change notification settings - Fork 0
/
CharInputOutput.py
34 lines (26 loc) · 915 Bytes
/
CharInputOutput.py
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
27
28
29
30
31
32
# Validation of name which checks that no number should be there
def containsDigits(nameToBeValidated=""):
###Checks whether string is a digit or not
# Input : any string value which nees to be validated
# Output: bool indicating whether its digit or not
if(nameToBeValidated.isdigit()):
return True
else:
return False
#Validation of age which checks that only numeric characters must be there
def IsNumber(numToBeValidated):
try:
int(numToBeValidated)
return True
except(ValueError):
return False
name = input("Please enter your name :")
print("You entered :" + name)
keepChecking = True
while(keepChecking):
enterdVal = input("Enter any number : ")
if(containsDigits(enterdVal)):
print("You entered :" + enterdVal)
keepChecking = False
else:
print("You did not entered a number. Please try again.")