【发布时间】:2022-11-18 13:03:38
【问题描述】:
我在 Visual Studio 上尝试更新我的 Itch Quiz Game,当我尝试测试一个带有打印函数的 Else 函数时,它说我有一个 Expected Expression 错误。我试图修复它,但没有用。请帮忙
这是我的代码
import time
print("Math Game")
print("")
score = 0
#intro
print("Welcome to 5 Questions")
answer6 = input("Type Begin to Begin")
if answer6 == "Begin":
score +=0
#Question 1
print("Whats 2 + 2")
answer1 = input("Enter answer")
if answer1 == "4":
else: ---THIS IS THE ERROR
print("Test")
score += 1
#Question 2
print("Whats 4 * 2")
answer2 = input("Enter answer")
if answer2 == "8":
score += 1
#Question 3
print("Whats the root square of 16")
answer3 = input("Enter answer")
if answer3 == "4":
score += 1
#Question 4
print("Who made the laws of gravity")
answer4 = input("Enter answer")
if answer4 == "Issac Newton":
score += 1
#Question 5
print("Whats Apples frist device the Phone or the Computer")
answer4 = input("Enter answer")
if answer4 == "Computer":
score += 1
print("you got " + str(score) + "/5")
time.sleep(5)
print("Good Bye!")
【问题讨论】:
-
您缺少
if语句的正文。并且else:需要与匹配的if处于相同的缩进级别。 -
顺便说一句,你拼错了“答案”。
-
你应该使用
score += 1而不是else:。像所有其他问题一样。
标签: python