Conway's Game of Life not counting neighbors correctly
问题 I am doing the standard Conway's Game of Life program using Python. I am having an issue when trying to count neighbors as I iterate through the array. I created print statements that print the succession of the if statement, as well as the value of count for each statement. Here is my code: ( I have the questions inside the # throughout the code) import random numrows = 10 numcols = 10 def rnd(): rn = random.randint(0,1) return rn def initial(): grid = [] count = 0 for x in range(numrows):