首页 > 解决方案 > 初学者:不明白我的代码的错误在哪里

问题描述

我从昨天开始学习python,在学习了一些基础知识后我尝试自己编写代码。如果我不了解基础知识,我将无法继续。请查看我的代码并向我解释我的错误。

x=input()
if(x==10):
    print("the number is 10")
    elif(x>=10):
        print("the number is more than 10")
        else:
            print("the number is less than 10")

 File "..\Playground\", line 4
    elif(x>=):
       ^
SyntaxError: invalid syntax

标签: python-3.x

解决方案


input返回一个字符串,但你想要一个int,你的标识也很错误:

x=int(input())
if(x == 10):
    print("the number is 10")
elif(x >= 10):
    print("the number is more than 10")
else:
    print("the number is less than 10")

推荐阅读