我正在完成一个基于文本的游戏,用于介绍python类.它不完整但我正在处理main_menu函数以及在遇到此错误消息时在main_menu函数内调用的函数.我在学习经历中多次遇到过这个错误,这通常归因于分配变量时的一个基本错误,但是这个让我感到困惑......这是有问题的脚本(回溯中的行以BOLD命名):
import random
from sys import exit
# Item variables
coal = ('Coal', 'some coal which can be used in a furnace.')
eng_key = ('Key', 'a key to a house.')
bomb = ('Bomb', 'a combustible device which creates a powerfull explosion. Possibly used for demolition...')
tonic = ('Tonic', 'a weak healing tonic. Adds \'5\' health points.')
sTonic = ('Super Tonic', 'a strong healing tonic. Adds \'10\' health points.')
# LOCATIONS
# Below are the possible locations you can …Run Code Online (Sandbox Code Playgroud)