这是我的刽子手计划。它返回一个“NameError:name'a'is not defined.”请帮助我解决这个问题。非常感谢你。在import random
invalid= [" ","'",".",",","'", '"', "/", "\ ", '"',";","[","]", "=", "-", "~", "`", "§","±","!","@","#","$","%","^","&","*","(",")","_","+","{","}","|",":","?",">","
choice = 0
print("Welcome to HANGMAN!")
def Menu():
print("[1] Play Hangman")
print("[2] Instructions ")
print("[3] Highscores")
print("[4] Exit")
choice = int(input("Please choose from the Menu: "))
if(not(choice <=4)):
print("Choose again.")
return Menu()
return choice
while True:
choice = Menu()
if choice == 1:
print("Categories: ")
print("[1] Movies")
print("[2] Animals")
print("[3] Something Blue")
choice_category = int(input("Please Choose a Category: "))
print("-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-")
print("Difficulties:")
print("[1] Easy")
print("[2] Average")
print("[3] Difficult")
choice_difficulty = int(input("Please Choose a Difficulty: "))
superword = a(choice_category, choice_difficulty)
legitgame(superword)
elif choice == 2:
print("Let yourself be hanged by mistaking the letters.")
elif choice == 3:
readHandle = open("Scores.txt","r")
names = []
for line in readHandle:
name = line[:-1]
names.append(name)
readHandle.close()
print()
Menu()
elif choice == 4:
print("Thank you for playing.")
Menu()
hangman =[" =========="
" | |"
" O |"
" |"
" |"
" | ",
" =========="
" | |"
" O |"
" | |"
" |"
" | ",
" ========== "
" | |"
" O |"
" /| |"
" |"
" | ",
" =========="
" | |"
" O |"
" /|\ |"
" |"
" | ",
" =========="
" | |"
" O |"
" /|\ |"
" / |"
" | ",
" =========="
" | |"
" O |"
" /|\ |"
" / \ |"
" | "]
针对特定类别和难度的不同选项的定义函数
定义a(选择类别,选择困难):
^{pr2}$