I'm trying to learn programming with python by myself and I've made a hangman game for exercise purposes.import randomwords = ['egypt', 'automobile', 'world', 'python', 'miniority', 'treehouse', 'friend', 'program' , 'people']def start():    print Hello! Welcome to a tiny hangman game that I made for exercise purposes.    raw_input('Press enter to continue')    key = random.randint(0,(len(words)-1))    global word    word = words[key]    global word_template    word_template = '_' * len(word)    word_template = list(word_template)    guesser()def draw(int):    if int == 0:            print  _________             print |         |            print |                      print |                      print |                      print |                      print |                  elif int == 1:        print  _________             print |         |            print |         0            print |                      print |                      print |                      print |                  elif int == 2:        print  _________             print |         |            print |         0            print |         |            print |                      print |                      print |                  elif int == 3:        print  _________             print |         |            print |         0            print |        /|            print |                      print |                      print |                  elif int == 4:        print  _________             print |         |            print |         0            print |        /|\\          print |                      print |                      print |                  elif int == 5:        print  _________             print |         |            print |         0            print |        /|\\          print |        /             print |                      print |                  elif int == 6:        print  _________             print |         |            print |         0            print |        /|\\          print |        / \\          print |                      print |              def guesser():    global counter    counter = 0    checker = list(word)    guesses = []    while counter < 6:        draw(counter)        print word_template        print '\nYour previous letters are:',  guesses        print 'You have ',(6 - counter), 'guesses left.'        choice = raw_input('Choose a letter: ')        if choice in guesses:            print \nYou made that guess before!        elif choice in checker:            if checker.count(choice) == 1:                pointer = checker.index(choice)                word_template[pointer] = checker[pointer]                checker[pointer] = 1                guesses.append(choice)                print \nThat's a hit!                if list(word) == word_template:                    win()                else:                    continue            elif checker.count(choice) > 1:                for i in range(0, checker.count(choice)):                    pointer = checker.index(choice)                    word_template[pointer] = checker[pointer]                    checker[pointer] = 1                guesses.append(choice)                print \nWOW! That was a multiple hit!                if list(word) == word_template:                    win()                else:                    continue        elif choice not in checker:            guesses.append(choice)            counter += 1            print '\nMiss!'    if counter == 6:        draw(counter)        print 'Sorry, you lose :('        print 'The word was:', word        retry()def win():    print \nYou won!    print You found the word:, word    retry()def retry():    print Do you want to play again?    choice = raw_input('Type retry for restart, Ctrl + C for exit:')    if choice == 'retry':        start()    else:        print Sorry, I can't understand.        retry()start()Is there any flaws on my logic and what can you suggest me to improve my code?
Hangman from a beginner
python;beginner;python 2.7;hangman
Avoid global variablesInstead of using global variables,it would be better to reorganize the code so that values are passed around in function parameters as necessary.Don't use int as variable nameint is the name of a built-in type.Don't use it as a variable name.It prevents the rest of the code from using it,and it's confusing for readers.Don't use recursive menuIn the current implementation the menu uses recursive logic:start calls guesser, which will call win or retry,which will again call start, or retry, and so on. This is all very confusing, and leads to a long stack.Rewrite this to use a loop for the game menu instead of recursion.Use the print functionI know you tagged your question with python-2.7, but with the simple change of print something to print(something) you get something that works just as well, and you're one step closer to compatibility with Python 3, and building a good habit.