我需要你的帮助。到目前为止,这是我的程序
import turtle
turtle.showturtle()
def turtle_interface():
while True :
n = 0
instructions = input().split()
i = instructions[0]
if len(instructions) > 1:
n = int(instructions[1])
if i == 'forward' :
turtle.forward(n)
elif i == 'backward' :
turtle.backward(n)
elif i == 'left' :
turtle.left(n)
elif i == 'right' :
turtle.right(n)
elif i == 'quit' :
break
elif i == 'new' :
turtle.reset()
else :
continue
print('Control the turtle!')
turtle_interface()
如您所见,当字符串后面没有 [n] 时,它会被忽略。我怎样才能解决这个问题?