我是python编程的新手。我在elif
声明中遇到问题。我无法找出语法错误。我的代码如下。
for num in range(1,31):
if (num%5 == 0) or (num%3 == 0):
if (num%3 == 0):
print ("beep")
elif (num%5 == 0):
print ("boop")
else:
print ("beepboop")
else:
print (num)
答案 0 :(得分:2)
错误的缩进
for num in range(1, 31):
if (num % 5 == 0) or (num % 3 == 0):
if num % 3 == 0:
print("beep")
elif num % 5 == 0:
print("boop")
else:
print("beepboop")
else:
print(num)