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行出现语法错误。我用小饰品做的。我的第一个项目。我把它放在小饰品里。在steamforVietNam每周挑战

  1. ===不同。CCD_ 3用于比较。=用于分配。

  2. 你在用python 2.7吗?应该是print("I can't understand what are you saying, can you say that again?")

  3. 要比较字符串时,请确保使用' '" "

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{^-^}")
elif o == 'n':
print("Thanks for playing{^-^}")
else:
print("I can't understand what are you saying, can you say that again?")

正如@Sujay所提到的,您在以下方面存在问题:

  • 标识
  • print语句语法
  • 指定变量

此外,如果您计划以某种方式使用用户输入(不清楚您想要什么(,请将其放在乌龟笔上方:

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()

相关内容

最新更新