python-3.x - 初学者:不明白我的代码的错误在哪里
问题描述
我从昨天开始学习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
解决方案
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")
推荐阅读
- python - 无法在另一个 jupyter 笔记本中导入模块
- pine-script - 如何在成交量 SMA 乘数上绘制买入和空头信号
- google-apps-script - GAS - 使用 Map 来检查一个数组和另一个数组
- html - HTML5 Canvas addColorStop 问题
- android - Flutter - 我无法从自己的 Api 获取数据,但从公共 API 获取数据有效
- reactjs - 使用 styled-component 的 Safari 上的 CSS 转换(部分)不起作用
- python - 函数定义只能调用一次然后不会运行
- windows - Curl Powershell windows 10 为什么比命令提示符慢?
- typescript - 为什么 TypeScript 不检查这个字典键的类型?
- javascript - Javascript 事件不适用于 Element.animate()