In python you can create a list like so:
[[0,0]]*n
This creates a list such as this:
[[0, 0], [0, 0], [0, 0]]
The issue is when you update the list such as:
li[0][0]=10
[[10, 0], [10, 0]开发者_如何学Python, [10, 0]]
Is there anyway to create lists of a certain size with this method but not encountering this problem?
I created this workaround but is there a better way?
for x in range(players):
li+=[[0]*n]
li = [[0,0] for i in range(players)]
精彩评论