Python Conway's Game of Life

前端 未结 1 755
轮回少年
轮回少年 2021-01-21 10:43

I\'m trying to make Conway\'s Game of Life where the user enters how big they want the grid and which cells start off as alive. Here\'s what I have:

def firstBo         


        
1条回答
  •  醉梦人生
    2021-01-21 11:11

    The problem is with your array initialization:

    newList = myList
    

    This isn't making a copy of myList, it's just making newList refer to myList, so then you only have one array. You can copy a 2D array like this:

    from copy import copy, deepcopy
    
    newList = deepcopy(myList)
    

    0 讨论(0)
提交回复
热议问题