Quantcast
Channel: Jannich Brendle's blog » python
Viewing all articles
Browse latest Browse all 7

Difference between two lists in python – a simple solution

$
0
0
Sometimes, you have two lists in python and you need too know the difference between two lists. With a quick list comprehension, this is easy to find out: numbers = [1,2,3,4,5,6,7,8] even = [2,4,6,8,10] difference = [ a for a in numbers if not a in even ] print difference The output should be: [1, [...]

Viewing all articles
Browse latest Browse all 7

Trending Articles