Voting Eligibility Check

Easy ⏱ 8 min 72% acceptance ★★★★☆ 4.4
Write a function can_vote(age, is_citizen) that returns True if a person is at least 18 years old and a citizen, and False otherwise.

Examples

Example 1
Input
can_vote(20, True)
Output
True
Explanation

Meets both conditions.

Example 2
Input
can_vote(20, False)
Output
False
Explanation

Not a citizen, so ineligible regardless of age.

Constraints

  • age is a non-negative integer.
  • is_citizen is a boolean.

Topics

Conditional Statementsif/else

Companies

TCSCapgemini

Hints

Hint 1

Combine both conditions with the `and` operator.

Hint 2

You can return the boolean expression directly without an if statement.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.