I'm working on a small task from the checkio-python coding game. It involves hard-scripting the built-in functions min() and max().
Anyway to "store" the minimal or maximal value, I thought of initializing a variable first and then store the respective lowest or highest value in it.
min_value = None
...function to compare element 1 with element 2 of a list and find lowest..
min_value = lowest_value
...function continues
When I realized that I had forgotten to compare the min_value with the lowest_value, to make sure that I would have the "globally" lowest value (of the whole list). But when I compare it, it gives me a NoneError with the first initialized variable.
min_value = None
...function to compare element 1 with element 2 and find lowest..
if lowest_value < min_value:
NoneError
So how could I initialize a value without a value, which has in this case also the highest possible value, which then would change after the first comparison.
I hope, I that I was able to make my question clear.
Thanks!