Menu

Sign in to track your progress and unlock all features.

Theme style

Log in

Full lesson preview

Validate Voter Age

Check whether a person is old enough to vote (18+).

Python practice6 minControl Flow (If–Else Logic)BeginnerLast updated March 15, 2026

Problem statement

Write a function is_eligible_voter(age) that takes an integer age and returns True if the age is 18 or older (eligible to vote), otherwise returns False. Handle unexpected ages (e.g., negative values) by returning False.

Task

Use if/else to return True when age is 18 or older, otherwise return False.

Examples

Simple eligibility

Input

18

Output

True

Age 18 is eligible.

Input format

A single integer argument: age.

Output format

Return a boolean: True if age >= 18, otherwise False.

Constraints

Age will be an integer. Treat negative ages as not eligible.

Samples

Sample 1

Input

20

Output

True

20 is >= 18, so eligible.