TIM0
TIM0

Reputation: 11

How to test for a range of inconsistent values

I need to test in python if x equals a series on inconsistent numbers for example 1, 2, 7, 9, 32, 98

Is their something I can use that wouldn't take forever? I know I could type

if x == 1 or x== 2 or x ==7 or x== 9 ...:
    [code here]

is there a quicker way to type this in the Python syntax?

Upvotes: 1

Views: 48

Answers (1)

SashaMN
SashaMN

Reputation: 708

if x in [1, 2, 7, 9, ...]:
    [code here]

Upvotes: 1

Related Questions