Editor

Remove Every Copy

#513 · Lists · Beginner · 25 XP · about 4 min

The list method remove takes out only the first copy of a value. Write remove_all(items, value) that returns a new list with every copy of value taken out and everything else kept in its order.

The original list must not change.

Examples

remove_all([1, 2, 1, 3, 1], 1)              # returns [2, 3]
remove_all(['tea', 'cake', 'tea'], 'tea')  # returns ['cake']
remove_all([4, 5], 9)                      # returns [4, 5]

Fastest solvers

Leaderboard

First solves only, ranked by stars and then time.