Else statement executing when it shouldnt
rosuav at gmail.com
Mon Jan 21 05:52:12 CET 2013
On Mon, Jan 21, 2013 at 3:40 PM, eli m <techgeek201 at gmail.com> wrote:
> an else statement is running when it shouldnt be. It is on the last line. Whenever i am in the math or game function, when i type in main, it goes back to the start of the program, but it also says not a valid function. I am stumped!
Check your indentation levels. I see a few things here that look odd:
> if function == "help":
> while helpfunc == 0:
> if helpmain == "main":
What is the else meant to bind to? The innermost if? The 'if function
== "help"'? It's currently binding to the while.
Recommendation: Break this up! Your main loop is huge! It's way too
easy to get lost in it. And while you're at it, consider unifying some
of the similar blocks of code. The solution to both issues is simple:
Use functions. Have you been taught about them yet?
Also, side tip: Be honest about homework. I'm fairly sure that's what
this is. :)
More information about the Python-list