我需要能够向用户询问乌龟命令,例如 forward(90) 并将其作为乌龟命令执行,例如 turtle.forward(90) 并重复直到用户退出。到目前为止,我有:
def turtle_input(prompt):
"""Loop to ask for user input and execute as a turtle command"""
import turtle
while True:
t = input('Enter a turtle command: ')
if t in ['Quit' , 'quit', 'q', 'Q']:
break
turtle.(t)
return prompt