python - Finding elements not in a list -


so heres code:

item = [0,1,2,3,4,5,6,7,8,9]  item in z:     if item not in z:         print item 

z contains list of integers. want compare item z , print out numbers not in z when compared item. can print elemtens in z when compared not items, when try , opposite using code above nothing prints.

any help?

your code not doing think think doing. line for item in z: iterate through z, each time making item equal 1 single element of z. original item list therefore overwritten before you've done it.

i think want this:

item = [0,1,2,3,4,5,6,7,8,9]  element in item:     if element not in z:         print element 

but like:

set(item) - set(z) 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -