python - SyntaxError:小饰品 main.py 中第 16 行的错误输入
问题描述
import turtle
pen = turtle.Turtle()
pen.speed(10000000000)
pen.color("green", "red")
pen.begin_fill()
for i in range(100):
pen.forward(209)
pen.left(421)
pen.right(312)
pen.hideturtle()
turtle.done()
o == input("Do you love it?y/n")
**if o == y:**
print"Thanks, please love for me{^-^}"
if o == n:
print"Thanks for playing{^-^}"
else:
print"I can't understand what are you saying, can you say that again?
在第 16 行语法错误中,我在 trinket 中做到了我的第一个项目我把它放在 trinkets 中在 steamforVietNam 每周挑战
解决方案
正如@Sujay 提到的,你有以下问题:
- 认同
- 打印语句语法
- 分配变量
此外,如果您打算以某种方式使用用户输入(不清楚您想要什么),请将其放在海龟笔上方:
import turtle
o = input("Do you love it?y/n")
if o == "y":
print("Thanks, please love for me{^-^}")
if o == "n":
print("Thanks for playing{^-^}")
else:
print("I can't understand what are you saying, can you say that again?")
pen = turtle.Turtle()
pen.speed(10000000000)
pen.color("green", "red")
pen.begin_fill()
for i in range(100):
pen.forward(209)
pen.left(421)
pen.right(312)
pen.hideturtle()
turtle.done()
推荐阅读
- ios - SwiftUI 代码将一个对象数据分配给数组中的所有其他对象?
- python - 根据后缀重构数据框
- javascript - 如何按我在列中的名称搜索特定文件夹中的文件并将其 URL 返回到电子表格,每个文件都在其特定行中?
- python - 动态添加枚举属性
- php - 如何将类作为参数传递给 PHP 函数
- grafana - Grafana 中是否有用于查看仅触发警报的图表的 URL 参数?
- swift - 如何在不区分大小写的情况下过滤数组?
- android - 在 NativeScript Angular 中导航嵌套路由
- pandas - 尝试在不暴露用户凭据的情况下将 Pandas 与 PostgreSQL 连接
- r - 如何在一张图中绘制单独堆叠的多条线?(Y 轨迹偏移)