I am having trouble understanding why this function works in python (it takes a list in as an argument):
def minimax(x): minimum = maximum = x[0] for i in x[1:]: if i < minimum: minimum = i elif i > maximum: maximum = i return (minimum,maximum)
What does "minimum = maximum = x[0]" in the second line do? How does python "know" what the words "maximum" and "minimum" are referring to?
minimum = maximum = x[0]
Is the same as
minimum = x[0] maximum = x[0]
it knows what they are(numbers) because you created the variables and assigned a value to them
1.4m articles
1.4m replys
5 comments
57.0k users