Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
初级Python 3语法_Python_Syntax_Python 3.x - Fatal编程技术网

初级Python 3语法

初级Python 3语法,python,syntax,python-3.x,Python,Syntax,Python 3.x,我一直在用python编写一个简单的测试,但在我的python GUI中不断得到一个“SyntaxError:编译单个语句时发现多个语句”。请帮忙 print("Welcome to my quiz!") score = 0 question1 = str(input("What colour is a banana.")) if question.lower() == 'yellow': print("Correct. The answer is", question1) sc

我一直在用python编写一个简单的测试,但在我的python GUI中不断得到一个“SyntaxError:编译单个语句时发现多个语句”。请帮忙

print("Welcome to my quiz!")
score = 0
question1 = str(input("What colour is a banana."))
if question.lower() == 'yellow':
    print("Correct. The answer is", question1)
    score = score + 1
else:
    print("Incorrect. The answer is yellow, not", question1)
print score

你有几个问题。首先,
问题
未定义(第4行);这应该是
问题1
。其次,
print
是Python 3中的一个函数,所以最后一行应该是
print(score)
。第三,
input
已经返回了一个字符串,因此不需要调用
str
。所以第3行应该是这样的:

question1 = input("What colour is a banana.")

Python3中没有
raw_输入
。@PavelAnossov噢,见鬼。这就是我在没有安装Py3的情况下发布Py3问题的结果。固定:)