G
G
gleb2702018-04-05 10:53:44
Python
gleb270, 2018-04-05 10:53:44

How to properly declare a python array so that there are no references?

I declare a two-dimensional array
a=*5
when adding values ​​to the array
a[0].append(1)
the value appears everywhere because array refers to one object how to remove it without handicaps

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2018-04-05
@gleb270

a = [[] for _ in range(5)]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question