Skip to content

Commit dcb1fc5

Browse files
authored
Inline condition
Don't initialize the 'status' variable twice also inline condition and f-string make code more readable.
1 parent 9bb97c0 commit dcb1fc5

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

python/age.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,5 @@
22
age = int(input("Enter Age : "))
33

44
# condition to check voting eligibility
5-
if age>=18:
6-
status="Eligible"
7-
else:
8-
status="Not Eligible"
9-
10-
print("You are ",status," for Vote.")
5+
status="Eligible" if age>=18 else "Not Eligible"
6+
print(f"You are {status} for Vote.")

0 commit comments

Comments
 (0)