Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ometimes you have to fix others bad programs. Get this program to successfully r

ID: 3719502 • Letter: O

Question

ometimes you have to fix others bad programs. Get this program to successfully run. You can modify it any way you need to so it will run. The core concept has to stay the same though for this program. It needs to be a hangman game.

Bonus points if you put a actual stick figure into the program while its running.

word_bank = ["jump", "run", "dive", "care", "smoke", "pipe", "left", "right", "hand", "finger", "bone", "pink", "peach"]
from random import randint
scoreboard = []

def generate_word(words):
    return list(words[randint(0,12)])

word = generate_word(word_bank)


for letter in word:
    scoreboard.append('__')



print "Try to guess this word: "
print " ".join(scoreboard)
print word
count = 5
print str(count) + " misses left."
for guess in range(50):
    guess = raw_input("Guess a letter: ")
    if guess not in word:
        count = count - 1
        print str(count) + " misses left."
        if count == 0:
            print "You lose! The word is " + "".join(word) + "."
            break
        else:
            continue
    else:
        index = word.index(guess)
        scoreboard[index] = guess
        print " ".join(scoreboard)
        if scoreboard == word:
            print "You win!"
            break

Python!!

Explanation / Answer

OUTPUT :

Try to guess this word:
l e f t
['l', 'e', 'f', 't']
5 misses left.
Guess a letter: a
4 misses left.
Guess a letter: e
l e f t
You win!