Trouble Understanding O'Reilly Example

slyraymond sly_raymond at charter.net
Sun Apr 25 23:56:20 EDT 2004


On page 214 of _Learning Python_, the following function is described as one
that will return the smallest item in a group of arguments:

def min1(*args):
  res = args[0]
  for arg in args[1:]:
    if arg < args:
      res = arg
  return res

However, when the function called with...

print min1(3,4,1,2)

...it returns:

2

Why?



More information about the Python-list mailing list