Answer the question
In order to leave comments, you need to log in
I enter 8 9 10 min() selects 9 max() 10. max - min = -1. How so?
I know it's a stupid question. But why does it work the way it does?
see code
#Входные данные: 8 9 10
s = input()
s = s.split()
max = max(s)
min = min(s)
print(int(max) - int(min))
Answer the question
In order to leave comments, you need to log in
Because you need to read the documentation for the max function
. If you pass strings to max\min, it will find a string (!) that matches lexigraphically, that is, in alphabetical order.
The string '10' < '9' because 1 comes before 9.
No need to redefine built-in names. Consider them reserved and unavailable for variable naming
max = max(s)
min = min(s)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question