How to find the maximum of 2 numbers?
value = -9999
run = problem.getscore()
I need to compare the 2 values i.e value
and
You can use max(value, run)
The function max takes any number of arguments, or (alternatively) an iterable, and returns the maximum value.
Just for the fun of it, after the party has finished and the horse bolted.
The answer is: max()
!
You could also achieve the same result by using a Conditional Expression:
maxnum = run if run > value else value
a bit more flexible than max
but admittedly longer to type.
I noticed that if you have divisions it rounds off to integer, it would be better to use:
c=float(max(a1,...,an))/b
Sorry for the late post!