Answer:
See explaination for the program code.
Step-by-step explanation:
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
for row in table:
print(*row,sep='')
Direction = input('Direction: ')