python的全称_未定义python名称

这是我的刽子手计划。它返回一个“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}$

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值