How to pass out the result from iterated function

Rhodri James rhodri at
Thu Dec 11 01:33:32 CET 2008

On Wed, 10 Dec 2008 20:16:56 -0000, JD <Jiandong.Ge at> wrote:

> I got a iterated function like this:
> def iterSomething(list):
>     has_something = False
>     for cell in list:
>         if something in cell:
>             has_something = True
>             output = something
>    if has_something:
>        iterSomething(output)
>    else:
>        final_out = outupt
> The problem is how can I read this final_out outside of the function.
> I tried the global statement, it seems not work. Any idea?

Isn't this going to throw an exception anyway if 'something' doesn't  
appear in 'list'?  You try assigning 'output' to 'final_out' with no  
guarantee that 'output' has ever been assigned to.

Rhodri James *-* Wildebeeste Herder to the Masses

More information about the Python-list mailing list