Ошибка в программе "чертёжный автомат" python.

Иван python

Новичок
Пользователь
Июн 3, 2021
14
0
1
Здравствуйте у меня не работает программа. Помогите пожалуйста! Вот код:

from turtle import *
def turtle_controller(do, val):
do = do.upper()
if do == 'F':
forward(val)
elif do == 'B':
backward(val)
elif do == 'R':
right(val)
elif do == 'L':
left(val)
elif do == 'U':
penup()
elif do == 'D':
pendown()
elif do == 'N':
reset()
else:
print('Unrecognized command')
def string_artist(program):
cmd_list = program.split('-')
for command in cmd_list:
cmd_len = len(command)
if cmd_len == 0:
continue
cmd_type = command[0]
num = 0
if cmd_len > 1:
num_string = command[1:]
num = int(num_string)
print(comand, ':', cmd_type, num)
turtle_controller(cmd_type, num)
instructions = '''Enter a program for the turtle:
eg F100-R45-U-F100-L45-D-F100-R90-B50
N = New drawing
U/D = Pen Up/Down
F100 = Forward 100
B50 = Backwards 50
R90 = Right turn 90 deg
L45 = Left turn 45 deg'''
screen = getscreen()
while True:
t_program = screen.textinput('Drawing Machine', instructions)
print(t_program)
if t_program == None or t_program.upper() == 'END':
break
string_artist(t_program)

Вот ошибка:

Traceback (most recent call last):
File "D:\python\avtomat.py", line 1, in <module>
from turtle import *
File "D:\python\turtle.py", line 2, in <module>
forward(100)
NameError: name 'forward' is not defined
 

regnor

Модератор
Команда форума
Модератор
Июл 7, 2020
2 589
459
83
 

Форум IT Специалистов