Python 如何使用if语句检查函数内部的变量?
我正在做一个基于文本的黑客游戏。如何使用if语句检查函数内部的变量 错误:Python 如何使用if语句检查函数内部的变量?,python,python-3.x,Python,Python 3.x,我正在做一个基于文本的黑客游戏。如何使用if语句检查函数内部的变量 错误: Traceback (most recent call last): File "C:\Users\user\Desktop\Python Projects\TextHackingGame\Start.py", line 22, in <module> if check == "start": NameError: name 'check' is not defined 声明变量时,请使用che
Traceback (most recent call last):
File "C:\Users\user\Desktop\Python Projects\TextHackingGame\Start.py", line 22, in <module>
if check == "start":
NameError: name 'check' is not defined
声明变量时,请使用
check=0
和check=0
,并在函数中使用StartOrChange()
def StartOrChange():
global Check
global check
print("Type 'Start' or 'Changelog'.")
Check = input("> ")
print (Check)
check = Check.lower()
global
进入一个试图更改全局值的函数。请确保此处的缩进与文件中的缩进相同。如果是相同的,那就是你的问题所在。
def StartOrChange():
global Check
global check
print("Type 'Start' or 'Changelog'.")
Check = input("> ")
print (Check)
check = Check.lower()