它说我有一个缩进错误。我找不到错误。我正在使用python空闲。
def main():
name = input("What is your name")
print("Hello " + name + "")
reason1 = input("Why do you think voting is important " + name + "?")
print("I agree, " + reason1 + "")
age = input("How old are you?")
if ( age >= 18 ):
print("Perfect, you can vote today!")
elif(0<int(age)<18):
useryears = 18-int(age)
print("You can't vote just yet, " + name + " you will be able to vote in " + str(useryears) + " years")
Print("Here's a tip, regester for early voting to skip the lines")
main()
答案 0 :(得分:1)
您需要调整print("Perfect, you can vote today!")
行。
name = input("What is your name")
print("Hello " + name + "")
reason1 = input("Why do you think voting is important " + name + "?")
print("I agree, " + reason1 + "")
age = int(input("How old are you?"))
if ( age >= 18 ):
print("Perfect, you can vote today!")
elif(0<age<18):
useryears = 18-age
print("You can't vote just yet, " + name + " you will be able to vote in " + str(useryears) + " years")
print("Here's a tip, regester for early voting to skip the lines")
编辑:修复了我的代码中的“打印”问题,并添加了建议将“ age”变量设置为真正的整数。
答案 1 :(得分:0)
请检出if and else statemtent旁边的行。根据python中的缩进规则,应将其缩进一个选项卡。