My Hangman code has errors on line 40 , line 40
print ('_'+ end=' ')
My code:
import time
import random
print('Lets play hangman')
print("""
_______
| |
| O
| |
| \- -/
| |
| | |
| | |
____|____
""")
random_words = ['string', 'loop', 'python', 'print', 'run' , 'graphics window', 'variable', 'iteration', 'modules', 'module', 'input', 'logic', 'output ']
time.sleep(2)
print ("What level would you like to play at? Too bad, you get random! Better type it in tho...")
level_of_difficulty = "Random"
time.sleep(2)
print ("The program is now generating your word...")
if level_of_difficulty == 'Random':
generated_word = random.choice(random_words)
guessed = ''
lives = 7
while lives > 0:
missed = 0
print()
for letter in generated_word:
if letter in guessed:
print("Congrats ya dumb animal, you got one")
else:
print ('_'+ end=' ')
missed = missed + 1
if missed == 0:
print ('\n\nYou win!')
quit()
break
guess=input("Well what are you waiting for? guess a letter!:")
guessed = guessed + guess
if guess not in generated_word:
print ('\n People like you are the reason why the human race will fail')
print ('Fool')
lives = lives - 1
missed = missed + 1
print('your new lives value is ' + str(lives))
if lives < 7:
print(''' _______
| | ''')
if lives < 6:
print(' | O ')
if lives < 5:
print(' | | ')
if lives < 4:
print(' | \- -/ ')
if lives < 3:
print(' | | ')
if lives < 2:
print(' | | | ')
if lives < 1:
print(' | | | ')
if lives == 0:
print('___|___ ')
print('Game Over Boi')
print('The secret word was ' + str(generated_word) + "fool")
quit()