Ask coding questions

← Back to all posts
No variables equal to eachother
DanielAtherton (0)

Is there an efficient way to check if none of the four variables are the same as each other without using a lot of if statements. Trying to reduce cyclomatic complexity

Commentshotnewtop
CodeLongAndPros (963)

none of the four variable

Like:

if not (foo, bar, spam, eggs) == (foo, bar, spam, eggs)

malvoliothegood (709)

Have you example code?

Muffinlavania (735)
If var1!=var2 and var2!=var3 and var3!=var4:
    #Do stuff

Its not that long, you can just put them into one if statement