In [2]:
#!/usr/bin/python
import random

def hang_man():
    word = random.choice(["Fanta", "Pepsi", "DrPepper", "Sprite", "CocoCola", "FruitSnacks", "CheezIt", "VeggieSticks", "Motts", "Takis"])
    letters = 'ABCDEFGHIJKLMNOPQRSTUVWUXZabcdefghijklmnopqrstuvwxyz'
    attempts = 10
    guess = ''

    while len(word)> 0:
        main = ""
        miss = 0

        for letter in word:
            if letter in guess:
                main = main + letter
            else:
                main = main + "_" + ""

        if main == word:
            print(main)
            print("you won!!!")
            break
                
        print("guess a letter:", main)
        guesses = input()
                
        if guesses in letters:
            guess = guess + guesses
        else:
            print("Enter a valid character")
            guesses = input()
                    
        if guesses not in word:
            attempts = attempts - 1 
            if attempts == 9:
                print("you have 9 turns left")
                print(" --------")
            if attempts == 8:
                print("you have 8 turns left")
                print(" --------")
                print("     O      ")
            if attempts == 7:
                print("you have 7 turns left")
                print(" --------")
                print("     O      ")
                print("     |      ")
            if attempts == 6:
                print("you have 6 turns left")
                print(" --------")
                print("     O      ")
                print("     |      ")
                print("    /       ")
            if attempts == 5:
                print("you have 5 turns left")
                print(" --------")
                print("     O      ")
                print("     |      ")
                print("    / \     ")
            if attempts == 4:
                print("you have 4 turns left")
                print(" --------")
                print("   \ O      ")
                print("     |      ")
                print("    / \     ")
            if attempts == 3:
                print("you have 3 turns left")
                print(" --------")
                print("   \ O /    ")
                print("     |      ")
                print("    / \     ")
              
            if attempts == 2:
                print("you have 2 turns left")
                print(" --------")
                print("   \ O /|   ")
                print("     |      ")
                print("    / \     ")
            if attempts == 1:
                print("You have 1 turn left")
                print("Make it count")
                print("   \ O_|/   ")
                print("     |      ")
                print("    / \     ")
            if attempts == 0:
                print("You loose!")
                print("He's dead")
                print(" --------")
                print("     O_|    ")
                print("    /|\      ")
                print("    / \     ")
                print(word)
                break   

def exit():
    exitAnswer = input("Do you want to go again? Y or N?")
    if exitAnswer == "Y" or exitAnswer == "y":
        hang_man()
    elif exitAnswer == "N"or exitAnswer == "n":
        print("Have an amazing day!!!")
        print("Thank you so much for playing!!!")
    else:
        print("Y, y or N, n please")
        exit()                
                            
yourname = input("Enter your name")
print("welcome", yourname)
print("Try to guess the word within 10 attempts")
print("If you think you guess the word correct make sure you add an uppercase to the first letter in the word and the rest of the word are lowercase")
print("Guess the word from the word bank: Fanta, Pepsi, DrPepper, Sprite, CocoCola, FruitSnacks, CheezIt, VeggieSticks, Motts, Takis")
hang_man()
exit()
print()
Enter your nameNick
welcome Nick
Try to guess the word within 10 attempts
If you think you guess the word correct make sure you add an uppercase to the first letter in the word and the rest of the word are lowercase
Guess the word from the word bank: Fanta, Pepsi, DrPepper, Sprite, CocoCola, FruitSnacks, CheezIt, VeggieSticks, Motts, Takis
guess a letter: ______
e
guess a letter: _____e
S
guess a letter: S____e
p
guess a letter: Sp___e
r
guess a letter: Spr__e
i
guess a letter: Spri_e
t
Sprite
you won!!!
Do you want to go again? Y or N?y
guess a letter: _____
e
you have 9 turns left
 --------
guess a letter: _____
a
you have 8 turns left
 --------
     O      
guess a letter: _____
o
guess a letter: _o___
M
guess a letter: Mo___
t
guess a letter: Mott_
s
Motts
you won!!!

In [ ]: