ParseError:第31行的错误输入

时间:2013-09-13 15:45:06

标签: python python-3.x

# Module Inputs
import turtle

# Define Functions
def drawshape(s,l,c):
    angle = 360 / s
    a.pencolor(c)
    for i in range(s):
        a.forward(l)
        a.left(angle)

# Create Turtle
a = turtle.Turtle
a.pensize(5)
a.pendown()

# Title and Credits
print('Shape Drawer by Alex Thornton')

# While Loop
answer = 'y'
while True:
    if answer != 'y':
        break

    # Create Turtle Window
    wn = turtle.Screen()

    # Inputs
    sides = int(input("\nHow many sides? ")
    length = int(input('What length of sides? ')
    color = input('What colour? ')

    # Call Functions from Inputs
    drawshape(sides,length,color)

    # Exit (From Turtle Window)
    wn.exitonclick()

    # Input For Restart
    answer = input("\nAgain? (y/n) ")

# Exit Program
print("\nThank you for using this program!")
exit = input('Please press enter to exit.')

在长度输入上,我得到第31行输入错误的解析错误。该程序从用户输入边长,边数和形状颜色的输入。这是作为GCSE计算的家庭作业完成的。

1 个答案:

答案 0 :(得分:2)

您在前一行30以及第31行上缺少一个括号。由于行不完整,上一行中经常会出现一个解析错误。

sides = int(input("\nHow many sides? "))
length = int(input('What length of sides? '))

第13行还需要括号来创建Turtle的实例。

a = turtle.Turtle()