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

Dave Angel d at davea.name
Mon Jan 7 04:12:25 CET 2013


On 01/06/2013 09:07 PM, Jack Little wrote:
> Here is the code, my error is below the code in itallics 

This is a text mailing list, italics aren't generally visible.  If you
want to highlight a line, add a useful comment to it.

But the problem here is your scoping.  All those globals make no sense,
since the keyword only has an effect inside a function.  Then you define
a function simpstart(), but it's only four lines long, consisting of
four more global statements.  in other words, the function does nothing.

Then after some more top-level code, you define another function
path_lpt1(), but the definition is inside a conditional.  This is legal,
but not likely what you intended to do.

Then you define another function path_lpt2(), but end it suddenly after
the line p6=raw_input(....    I'd expect the next line to get an error,
referencing an unknown p6.

You have a line  health=100 immediately after a return statement, so
it'll never execute.

And as Oscar points out, you have a return at top-level code, which is
to say, not inside any function.

Not sure where you got this code, but there's probably lots more wrong; 
I only really looked at the indentation.  I think you're confusing
defining a function with calling it.  And i suspect you typed the whole
thing from a book or something, and just got the whole indentation wrong.



-- 

DaveA



More information about the Tutor mailing list