Question: Python question, i'm stuck with this one. The code i have below didn't produce the excat output. Please help. size = int(input('Grid size: ')) table
Python question, i'm stuck with this one. The code i have below didn't produce the excat output. Please help.

size = int(input('Grid size: ')) table = [] for i in range(size): row=[] for j in range(size): row.append('.') table.append(row) table[0][0] = 'x' for row in table: print(*row,sep='')
Direction = input('Direction: ') while Direction: if Direction == 'right': for i in range(size): for j in range(size-1): if table[i][j] == 'x': table[i][j+1] = 'x' table[i-1][j+1] = '.' break elif Direction == 'down': for i in range(size): for j in range(size-1): if table[j][i] == 'x': table[j+1][i] = 'x' table[j+1][i-1] = '.' break Direction = input('Direction: ')

You're familiar with the story of Hansel and Gretel, so when you decide to go exploring you always make sure to keep track of where you've come from. Since you know how unreliable leaving a trail of breadcrumbs is, you decide to write a program to help you map out your trail. Your program should first read in the size of the grid that you will be exploring, and then read in directions: left,right, up or down. You always start exploring at the top left of your map. After every step you should print out the trail, reading in directions until a blank line is entered. Your program should work like this: Grid size: 3 Direction: right Direction: dowrn Direction: right .Xx You will never be directed off the edges of the map
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
