Files
30-seconds-of-code/snippets/difference.md
Hodza Alban 33c653c36b Issue #19
2018-02-28 08:39:07 +01:00

14 lines
269 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### difference
Returns the difference between two iterables.
Use list comprehension to only keep values not contained in `b`
```python
def difference(a, b):
   return [item for item in a if item not in b]
```
``` python
difference([1, 2, 3], [1, 2, 4]) # [3]
```