Finding elements not in a list

前端 未结 10 788
一向
一向 2020-11-27 13:29

So heres my code:

item = [0,1,2,3,4,5,6,7,8,9]
z = []  # list of integers

for item in z:
    if item not in z:
        print item

z<

10条回答
  •  清歌不尽
    2020-11-27 14:10

    If you run a loop taking items from z, how do you expect them not to be in z? IMHO it would make more sense comparing items from a different list to z.

提交回复
热议问题