Filter Voting-Age Users

Easy ⏱ 8 min 78% acceptance ★★★★★ 4.8
Write voters(users) where users is a list of (name, age) tuples. Return only the tuples with age >= 18, using filter with a lambda.

Examples

Example 1
Input
voters([('Anu', 17), ('Raj', 21)])
Output
[('Raj', 21)]
Explanation

Only Raj is 18 or older.

Constraints

  • Use filter + lambda.
  • Return a list.

Topics

Lambda & Functionalfilter

Companies

MetaCognizant

Hints

Hint 1

filter keeps items where the predicate is truthy.

Hint 2

The predicate reads u[1].

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