Role Permission Checker

Medium ⏱ 12 min 50% acceptance ★★★★★ 4.7
Implement can_perform(required, granted) where both arguments are iterables of permission strings. Return True only if every required permission is included in the granted ones. An empty required always returns True.

Examples

Example 1
Input
can_perform(['read', 'write'], ['read', 'write', 'delete'])
Output
True
Explanation

Both required permissions are granted.

Example 2
Input
can_perform(['admin'], ['read', 'write'])
Output
False
Explanation

admin is missing.

Constraints

  • Handle any iterable inputs, not just lists.
  • Empty required set → True.

Topics

Setssubset/superset

Companies

OktaServiceNowIBM

Hints

Hint 1

Convert both to sets.

Hint 2

The <= operator tests "is subset of".

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