Python logoPython/
PTC-W0041

Consider using `min` builtinPTC-W0041

Major severityMajor
Anti-pattern categoryAnti-pattern

It is unnecessary to use an if statement to check the minimum of two values and then assign the value to a name. You can use the min built-in do do this. It is straightforward and more readable.

Not preferred:

if value >= 10:
    value = 10

Preferred:

value = min(value, 10)