Skip to content

Commit 9b4a8a2

Browse files
committed
Task 4: Take age from user and check age is eligible for voting
1 parent dcb2564 commit 9b4a8a2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Take age from user and check age is eligible for voting
2+
# Task 4:
3+
def voting_age(name,age):
4+
if age >= 18 and age <= 100:
5+
print(f'Hi {name}!. You are eligible for voting your age is {age}')
6+
else:
7+
print(f'Hi {name}!. You are not eligible for voting !!')
8+
9+
try:
10+
name,age=input('Enter the name and age with single whitespace: ').split(' ')
11+
voting_age(name,int(age))
12+
except ValueError:
13+
print('Enter the valid input')
14+
15+
# Output:
16+
# Enter the name and age with single whitespace: Harrish 19
17+
# Hi Harrish!. You are eligible for voting your age is 19
18+

0 commit comments

Comments
 (0)