0

ok, I have a list of numbers and i want to return values in a range that are not in the list of numbers...

I'm thinking of something like this:

[ number for number in range(1, 10) if != nums ]

However, This always prints all the numbers in that range...
I'm not sure what else i'm missing.

Thanks

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by rjmiller
0
>>> l=[1, 2, 3, 4, 5]
>>> l2=[number for number in range(1, 10) if not number in l]
>>> l2
[6, 7, 8, 9]

or something like this :

>>> l3=[]
>>> for number in range(1, 10):
    #if number in l: pass
    if not number in l:
        l3.append(number) #l3 += [number]
>>> l3
[6, 7, 8, 9]
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.