Python语法错误:期望一个预期的块

时间:2016-08-27 03:22:51

标签: python syntax-error

首先我点击了Run Module

So first i clicked on Run Module

然后出现

Error Image 2

我的代码

import time
    print("First we need to know you.")

print("Enter your name please.")
time.sleep(2)
name = input("Name: ")
print("Welcome, " + name + "!")
time.sleep(3)
criminal = input("Are you a criminal?: ")
if criminal=='Y':

就在这里,它突出显示为红色

 print('Oh no')
    elif criminal=='N':
    print('Thank god!')

2 个答案:

答案 0 :(得分:3)

您需要在ifelif

之后缩进
if criminal=='Y':
    print('Oh no')
elif criminal=='N':
    print('Thank god!')

另外,请勿在{{1​​}}:

之后缩进
import

答案 1 :(得分:1)

您必须缩进print('Oh no')

if criminal=='Y':
    print('Oh no')
elif criminal=='N':
    print('Thank god!')