So I'm trying to make a hang man game without YouTube and I have been stuck on this error for a while.
If you can see the error please help.
Traceback (most recent call last):
File "C:\Users\alfre\PycharmProjects\pythonProject\Coin flip.py", line 4, in <module>
for k, v in dictonary:
ValueError: too many values to unpack (expected 2)
At first I tried changing the long list to a python file:
from words import words
But it that does not work either.
I also tried lowering the number of words but that also did not work.
Current code:
import random
from words import words
# set up
hang_man = []
lose_game = \
[''' O
/|\
|
/ \ ''']
stage_1 = \
[''' O
''']
stage_2 = \
[''' O
/|\
''']
stage_3 = \
[''' O
/|\
|
''']
stage_4 = \
[''' O
/|\
|
/ \ ''']
scale = 0
# random word
def random_word():
return random.choice(words)
# actions
def word_action(player_pick):
if player_pick == random_word():
return True
else:
return False
def letter_action(player_choice):
if player_choice in random_word():
return True
else:
return False
# update
def update_hangman(scale1):
if scale1 == 0:
hang_man = stage_1[:]
print(stage_1)
scale1 = scale1 + 1
elif scale1 == 1:
hang_man = stage_2[:]
print(stage_2)
scale1 = scale1 + 1
elif scale1 == 2:
hang_man = stage_3[:]
print(stage_3)
scale1 = scale1 + 1
elif scale1 == 3:
hang_man = stage_4[:]
print(stage_4)
print('Sorry you lost')
quit()
return scale1
# main
def main():
while True:
print('Hang Man Game')
user = input('''We have our word.
Guess a letter or a word:'''.strip)
if len(user) == 1:
if letter_action(user) == True:
pass
else:
pass
elif len(user) > 1:
if word_action(user) == True:
print('That is the correct word.')
print('Good job you win.')
quit()
else:
update_hangman(scale)
print('Sorry that was the wrong word')
print('Try again')
elif user == int:
print('Please type a letter.')
else:
print('Please retype.')
And the list of words I used is:
words = ["aback","abaft","abandoned","..."] # and many more