簡單的程式碼,用Python 3 Jupyter Notebook
import random
List = [[0] * 3 ]*5
for m in range(0,5):
for n in range(0,2):
List[m][n] = random.randint(0,1)
print(List)
得到
[[0, 1, 0], [0, 1, 0], [0, 1, 0], [0, 1, 0], [0, 1, 0]]
欸不是,為什麼這樣會重複啦
害我只能寫很長一條來切...不然分段都會每段重複...