I'm making a a simple labyrinth. I want to make it so that I could hit a wall, and if I did hit the wall, I wouldn't cross it.from turtle import *from time import *speed(0)for a in range(0,401,20): sety(a); forward(400); #write(a); forward(-400);home()left(90)for a in range(0,401,20):  setx(a)  forward(400)  backward(400)home()map=[     '####################',     '#       #          #',     '# ####  ### # #### #',     '# #       # # #  # #',     '# #### #### #  # # #',     '#      #    # #    #',     '###### # #### ## # #',     '#    # #         # #',     '# #### ####### ### #',     '#            # #   #',     '# #  ##### ### # # #',     '# #  #   #         #',     '# #  #   # #### ## #',     '# ## ##### #  # ## #',     '#             #    #',     '# ########## ### # #',     '#   #      #     # #',     '### #### # ####### #',     '#S       #       # #',     '####################']delay(0)home(); sety(400)for row in map:  for cell in row:    if cell == ' ': color('black', 'black')    if cell == '~': color('black', 'red')    if cell == '#':      begin_fill()      for x in range(4):        forward(20)        right(90)      end_fill()    if cell=='S' or cell=='F':      if cell=='S':        color('green')      else:        color('yellow')      right(90)      forward(20)      left(90)      write(cell, font=(Arial, 14))      left(90)      forward(20)      right(90)    forward(20)  forward(-400)  right(90); forward(20); left(90)goto(20,20)color('black', 'green')begin_fill()for i in range(4):  forward(20); left(90)end_fill()write('S', font=(Arial, 14))hideturtle()setx(160)color('black', 'yellow')begin_fill()for i in range(4):  forward(20); left(90)end_fill()write('F', font=(Arial, 14))hideturtle()hero=Turtle()hero.color('pink')hero.penup()hero.speed(0)hero.goto(50,30)screen=getscreen()screen.listen()hero.row=8hero.col=2def W():  hero.clear()  hero.setheading(90)  hero.forward(20)  hero.row-=1  react_to_cell()  cell = map[hero.row][hero.col]  if cell == '#':      hero.forward(-20)      hero.row+=1def S():  hero.clear()  hero.setheading(-90)  hero.forward(20)  hero.row+=1  react_to_cell()  cell = map[hero.row][hero.col]  if cell == '#':      hero.forward(-20)      hero.row-=1def A():  hero.clear()  hero.setheading(180)  hero.forward(20)  hero.col-=1  react_to_cell()  cell = map[hero.row][hero.col]  if cell == '#':      hero.forward(-20)      hero.col+=1def D():  hero.clear()  hero.setheading(0)  hero.forward(20)  hero.row+=1  react_to_cell()  cell = map[hero.row][hero.col]  if cell == '#':      hero.forward(-20)      hero.row-=1def react_to_cell():    cell=map[hero.row][hero.col]    if cell==' ':         hero.write('ia negalima eiti', font=(Arial, 14))         hero.goto(50,30)         hero.setheading(0)         hero.row=18         hero.col=1    elif cell=='F':         hero.color('green')         color('red')         goto(-120,0)         write(u'Finias', font=(Arial, 20, 'bold'))screen.onkey(W,'Up')screen.onkey(S,'Down')screen.onkey(A,'Left')screen.onkey(D,'Right')
Simple labyrinth
python;beginner;turtle graphics