On Sat, Aug 1, 2015 at 2:03 PM, Válas Péter <tur...@64.hu> wrote: > Hi Stephanie, > > the function should be defined first, and used after. So put it before > main().
It's perfectly legal and ok to say: ########################### def main(): callHelper() def callHelper(): print("I am the helper") main() ########################### Rather, the problem is due to putting the helper function accidentally nested *within* main: ############################ def main(): callHelper() def callHelper(): print("I am the helper but can't be called until after the definition") main() ############################# One technical way to "fix" this is to move it up a bit: ############################# def main(): def callHelper(): print("I am the helper but can't be called until after the definition") callHelper() main() ############################# But this is usually unsatisfactory because we can't then access callHelper from outside. There can be valid reasons to hide function definitions at times, but this isn't one of those situations. Válas's suggestion, to move the helper's definition above, does make sense: ############################# def callHelper(): print("I am the helper but can't be called until after the definition") def main(): callHelper() main() ############################# but a key point needs to be made: don't just move it *up*, but move it *out*. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor