python-101
python-101 copied to clipboard
Remove redundant comparison in 32_stonks.py
The code for min_price can be improved by removing redundant comparison.
def min_price(a, b):
mn = price_at(a)
for i in range(a, b + 1):
mn = min(mn, price_at(i))
return mn
mn is initialized with the value of price_at(a) and that, however, means that the line where mn is updated becomes mn = min(price_at(a), price_at(a)), this is redundant and it's possible to skip it.