problems with code

Mel Wilson mwilson at the-wire.com
Wed May 21 21:48:43 EDT 2003


In article <3ECC1424.9020604 at shaw.ca>, cancal <cancal328 at shaw.ca> wrote:
>This script finds "Smith numbers" in the range passed to smith(). (Smith
>numbers are numbers the sum of whose digits equals the sum of digits in
>their prime factors.)
>
>At runtime a type error is raised: interation over non-sequence, at the
>line 'for each in flist' in the function pf(). pfactors() is a
>home-grown function that returns a list of the prime factors of its
>argument. It is working correctly and returning a valid list -- trust
>me.

   If it were, you wouldn't be getting the type error.  The
thing to do is bracket the "for each in flist ... fprod *=each"
with "try: ... except TypeError e: ... print flist" and
see what's really happening.

        Regards.        Mel.




More information about the Python-list mailing list