Drain the Raffle Drum

Easy ⏱ 8 min 86% acceptance ★★★★☆ 4.4
Write drain(entries) that takes a set of raffle entries and removes them one at a time with pop() until the set is empty, returning a list of the popped values in the order they came out. (The order is arbitrary — your function must simply not crash on the final pop.)

Examples

Example 1
Input
sorted(drain({'a', 'b'}))
Output
['a', 'b']
Explanation

Both entries come out (in arbitrary order) and the set ends empty.

Constraints

  • The input set must be empty afterwards.
  • Never raise KeyError.

Topics

Setspop

Companies

ZomatoHCLTech

Hints

Hint 1

while the set is truthy, keep popping.

Hint 2

set.pop() removes and returns an arbitrary element.

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