[Tutor] Here is code, no link for my previous question

Steven D'Aprano steve at pearwood.info
Mon Jan 7 04:00:43 CET 2013


And a second reply:

On 07/01/13 13:07, Jack Little wrote:

> def simpstart():
>    global ammo
>    global health
>    global tech_parts
>    global radio_parts

This function does nothing. It declares four globals, and then ends. All
the subsequent lines of code are not indented, and so are not part of the
function.

I am pretty sure that last time you asked about a problem with this code,
I told you the same thing. Why are you asking questions if you don't
listen to the answer? See my email on the tutor list on 15/12/12.

If you don't understand our answers, please ask for further clarification
rather than just ignore them. Ignoring answers will be a good way to have
your questions ignored too.



> else:
>    return path1_pt2()
>    "A snowstorm swept through, killing you."
>
>
> Here is the error:
>
> There's an error in your program:
> ***'return' outside function(g.py,line 179)

Is that error message not clear enough? You have an "return" statement
outside of a function. This is not allowed, because there is nothing
to return from, or return to.


When asking questions, please try to avoid sending your entire
program. Please try to narrow the problem down to the smallest
amount of code that fails. We're happy to *help*, but we're not
here to do your work for you.

In this case, the simplest example that gives you this error may be
something like this:


def test():
     print "inside function test"  # indented, inside function
return 1  # not indented, outside function



-- 
Steven


More information about the Tutor mailing list