Check Voting Eligibility

Check voting eligibility for a given age (18+).

IntermediatePhase 1 - Level 2: Nested If & Multiple ConditionsExample 6 of 10
check-voting-eligibility.py
1# Take age as input
2age = int(input("Enter age: "))
3
4# Check voting eligibility
5if age >= 18:
6 print("Eligible to vote")
7else:
8 print("Not eligible to vote")

Output

Enter age: 20
Eligible to vote

Enter age: 16
Not eligible to vote

What's going on

Use >= operator to check if age is 18 or above.

Key Concepts:

Voting age is 18 or above
Use >= to include 18
Simple if-else structure