PY3.R1714
Consider using in
To check if a variable is equal to one of many values,combine the values into a tuple and check if the variable is contained in it instead of checking for equality against each of the values. This is faster and less verbose.
Noncompliant Code:
Copy
def fruit_is_round(fruit):
return fruit == "apple" or fruit == "orange" or fruit == "melon"
Compliant Code:
Copy
def fruit_is_round(fruit):
return fruit in {"apple", "orange", "melon"}