leftcoord ( width rightcoord ( width abovecoord ( height belowcoord ( height nextwe need to use two nested for loops to calculate each cell for the next step the living or dead state of the cell depends on the neighborsso let' first calculate the index of the cells to the leftrightaboveand below the current xand -coordinates the mod operator performs "wraparound the left neighbor of cell in the leftmost column would be or - to wrap this around to the rightmost column' index we calculate ( width since width is this expression evaluates to this mod-wraparound technique works for the rightaboveand below neighbors as well count number of living neighborsnumneighbors if currentcells[leftcoord][abovecoord='#'numneighbors + top-left neighbor is alive if currentcells[ ][abovecoord='#'numneighbors + top neighbor is alive if currentcells[rightcoord][abovecoord='#'numneighbors + top-right neighbor is alive if currentcells[leftcoord][ ='#'numneighbors + left neighbor is alive if currentcells[rightcoord][ ='#'numneighbors + right neighbor is alive if currentcells[leftcoord][belowcoord='#'numneighbors + bottom-left neighbor is alive if currentcells[ ][belowcoord='#'numneighbors + bottom neighbor is alive if currentcells[rightcoord][belowcoord='#'numneighbors + bottom-right neighbor is alive to decide if the cell at nextcells[ ][yshould be living or deadwe need to count the number of living neighbors currentcells[ ][yhas this series of if statements checks each of the eight neighbors of this celland adds to numneighbors for each living one set cell based on conway' game of life rulesif currentcells[ ][ ='#and (numneighbors = or numneighbors = )living cells with or neighbors stay alivenextcells[ ][ '#elif currentcells[ ][ =and numneighbors = dead cells with neighbors become alivenextcells[ ][ '#elseeverything else dies or stays deadnextcells[ ][ytime sleep( add -second pause to reduce flickering lists