英文:
Why am I getting a Syntax error for this IF statement?
问题
> > `x = 18.0 If x < 18.5:
> > print("Less than 18.5")`
我预期它会打印,但实际上我得到了以下错误
If x < 18.5: ^ SyntaxError: 语法错误
我在Jupyter Notebook中使用Python 3。
a = 33 b = 200 if b > a: print("b is greater than a")
这段代码有效,但上面的代码不有效。
英文:
> > `x=18.0 If x < 18.5:
> > print("Less than 18.5")`
I'm expecting it to print but instead I get this error
If x < 18.5:
^
SyntaxError: invalid syntax
I'm using Python 3 in Jupyter Notebook.
a = 33
This code works but not the code above.
b = 200
if b > a:
print("b is greater than a")
答案1
得分: 1
The if
shouldn't be capitalized in your code.
英文:
The if
shouldn't be capitalized in your code.
答案2
得分: 1
你现在是大写的"if",而且你的缩进是错误的,应该看起来像这样:
x = 18.0
if x < 18.5:
print("小于18.5")
英文:
you are capitalizing if, also your indentation is wrong, it should look something like
x = 18.0
if x < 18.5:
print("Less than 18.5")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论