Python Forum
Hangman game, feedback appreciated
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hangman game, feedback appreciated
#11
(Jul-19-2018, 08:44 AM)WolfWayfarer Wrote: @Windspar: so there is a main() in Python too!
well, it's just a perception for main entry point in your script. you can designate any function to be the main one :-)

def foo():
    print('foo')

def bar():
    print('bar')

# this would be your 'main'
def enter_here():
    foo()
    bar()

if __name__ == '__main__':
    enter_here()
in python more important for the structure of the code/execution/imports is the use of if __name__ == '__main__': pattern/block. E.g. the above can be just
def foo():
    print('foo')

def bar():
    print('bar')


if __name__ == '__main__':
    foo()
    bar()
i.e. what you would put in your 'main' function it just can be inside if __name__ == '__main__': block. Using 'main' function doesn't hurt but is more or less a reflection of your programming habits/patterns from other languages.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  A hangman game. mcmxl22 1 2,067 Oct-07-2019, 02:02 PM
Last Post: ichabod801
  tk hangman game joe_momma 0 2,838 Aug-09-2019, 02:48 PM
Last Post: joe_momma
  Looking for feedback on a game I made MrPucake 7 4,232 Apr-04-2018, 01:53 PM
Last Post: MIPython

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020