python def函数中的空格太多或语法错误

时间:2017-12-31 01:34:31

标签: python syntax-error

if user_input == "3":
            print "You have selected difficult"
            answers = (["South Africa"])
            difficulty = "Difficult"
            quiz = quiz3
            x = 1
        else:
            print "Error - Choose 1, 2 or 3...\n"

        def run_quiz(quiz):

n = 0
global blank
print "Welcome to my Geography quiz!"

1 个答案:

答案 0 :(得分:1)

else需要与if位于同一标签上。然后是您要激活的代码,与ifelse

相同的垂直行中的一个标签(或四个空格)
if user_input == "3": 
    print "You have selected difficult" 
    answers = (["South Africa"]) 
    difficulty = "Difficult" 
    quiz = quiz3 
    x = 1 
else: 
    print "Error - Choose 1, 2 or 3...\n"