Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python programming Part III: Move Starman Down (15 points) Write a function move

ID: 3596156 • Letter: P

Question

Python programming

Part III: Move Starman Down (15 points) Write a function move down( ) that takes one argument, board, which represents the current state of the game board. Your function should move Starman down by one row, update the game board (if needed), and then retum Starman's new location as [row number, column number. Please nole that these are the real row and column numbers, not the indexes in the board list. Special rules apply please check General Tasks for Parts II through V above. Examples: boardl '',1, I'O.. board2 E CSE 101 - Fall 2017 Homework #3 Page 5 board3 t', E 11 Function Call Return Value move.down (boardl) 13, 2 move-down (board2) [-1, -11 Updated boards: board!= [[..,, ,.,, ,.,, ,.,, ,w, i, board2F.

Explanation / Answer

Solution:

def move_down(board):
for i in range(len(board)):
for j in range(len(board[i])):
if board[i][j] == '*':
board[i][j] = '.'
if i+1 < len(board):
board[i+1][j] = '*'
return (i+2, j+1)
return (i+1, j+1)

board1 = [['.', '.', '.', '.', 'W'],
['.', '*', '.', '.', '.'],
['.', 'F', 'O', 'F', '.'],
['.', '.', 'O', '.', 'W'],
['.', '.', 'O', '.', '.']]
print(move_down(board1))
print(board1)

Please, please upvote and ask your doubts in the comments.