Trouble Understanding O'Reilly Example
slyraymond
sly_raymond at charter.net
Mon Apr 26 04:44:57 EDT 2004
So the book contains a typo.
Hmm. What's amusing about this particular typo is that on the very next
page the authors give the result of the function call, and the erroneous
result is consistent with the code:
(from p. 215):
"C:\Python22>python mins.py
2"
...a double typo!
Chris wrote:
> slyraymond wrote:
>
>> def min1(*args):
>> res = args[0]
>> for arg in args[1:]:
>> if arg < args:
>> res = arg
>> return res
> Apologizing for whatever damage knode did to the formatting, try:
>
> if arg < res:
>
> instead of
>
> if arg < args
>
> For debugging purposes, add the line
>
> print args
>
> just before the return statement to see exactly what is going on.
>
> Chris
More information about the Python-list
mailing list