简体   繁体   English

调用函数时的语法错误

[英]syntax error when calling a function

quiz_again = str(input("Enter yes or no")
if quiz_again == "yes":
                 quiz()

I am tying to run this on python (idle version 3.4.2) but I am greeted with syntax error: invalid syntax and the cursor highlights the ":" If anyone could explain I would be very appreciative 我想在python(空闲版本3.4.2)上运行它,但是遇到语法错误:语法无效,并且光标突出显示“:”如果有人可以解释我将非常感激

You have an indentation issue. 您有缩进问题。 If a function quiz is defined, try it: 如果定义了功能quiz ,请尝试:

quiz_again = str(input("Enter yes or no"))
if quiz_again == "yes":
    quiz()

or it's possible to run: 或者可以运行:

quiz_again = str(input("Enter yes or no"))
if quiz_again == "yes": quiz()

正如Jim所指出的,您需要编写为:

quiz_again = str(input("Enter yes or no"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM