我正在尝试创建一个刽子手游戏。
Python一直告诉我get_word
没有定义,但我不确定它为什么这么说。
get_word():
dictionary = ["number","one","hyper","active","knuckle","head","ninja"]
import random
process_guess():
while keep_playing:
dictionary=["number","one","hyper","active","knuckle","head","ninja"]
word=choice(dictionary)
word_len=len(word)
guesses=word_len * ['_']
max_incorrect=7
alphabet="abcdefghijklmnopqrstuvxyz"
letters_tried=""
number_guesses=0
letters_correct=0
incorrect_guesses=0
print_game_rules(max_incorrect,word_len)
while (incorrect_guesses != max_incorrect) and (letters_correct != word_len):
clues()
letter=get_letter()
if len(letter)==1 and letter.isalpha():
if letters_tried.find(letter) != -1:
print ("letter has already been used", letter)
else:
letters_tried = letters_tried + letter
first_index=word.find(letter)
if first_index == -1:
incorrect_guesses= incorrect_guesses +1
print ("The",letter,"is not the unknown word.")
else:
print("The",letter,"is in the unknown word.")
letters_correct=letters_correct+1
for i in range(word_len):
if letter == word[i]:
guesses[i] = letter
else:
print ("Please guess a single letter in the alphabet.")
print("victory:",no guesses ')
play():
1 = yes
0 = no
print(("play again? (1-yes, 0-no")):
print("get the current guess letter:", current)
main()