[Tutor] What does "TypeError: 'int' object is not iterable" mean?

Christian Witts cwitts at compuscan.co.za
Thu Oct 21 15:12:31 CEST 2010

On 21/10/2010 14:42, Richard D. Moores wrote:
> Traceback (most recent call last):
>    File "c:\P26Working\test_urllib2_21a.py", line 148, in<module>
>      unchanged_count, higher_count, lower_count, secs =
> sleep_seconds_control(unchanged_count, higher_count, lower_count,
> secs)
> TypeError: 'int' object is not iterable
> I'm working on a script that keeps track of the USD ->  Japanese Yen
> exchange rate. I'm experimenting with adding functionality that
> changes the seconds to sleep between web scrapes, depending on
> consecutive outputs of no change in the exchange rate. Please see the
> code at<http://tutoree7.pastebin.com/KWmdk8jb>
> I'm at a loss as to what the error means.
> Thanks,
> Dick Moores
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor

You are expecting 4 items back from the sleep_seconds_control function 
but you only return 1 (seconds).  The left-hand side should either just 
be `secs = ...` or you should change your function to return all 4 items.

What the error means is that the interpreter is trying to iterate over 
the results from your function in order to divide it into the 4 
variables on the left-hand side.

Kind Regards,
Christian Witts

More information about the Tutor mailing list