I don't know why the whole column is changed for the code below.
from random import *
map=[]
lst=[]
for i in range(0,10):
lst.append(".")
for j in range(0,10):
map.append(lst)
col=randint(0,9)
row=randint(0,9)
if map[row][col]==".":
map[row][col]="ex"
print(map)
Output
[
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.']
]
Expected
[
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', 'ex', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.']
]
Aucun commentaire:
Enregistrer un commentaire