Use `tuple` unpacking to swap variablesPYL-R1712
It is recommended not to use a temporary variable in order to swap variables. Using tuple unpacking to directly swap variables makes the intention more clear.
Bad practice
Not preferred:
temp = a
a = b
b = temp
Recommended
a, b = b, a
swaps the values of a
and b
.