After using the Python extend function, an array mark appears in the list

Asked 2 years ago, Updated 2 years ago, 38 views

We created a list and wrote an extend() function that adds up the other lists in it. But the variable has the expression array(). For example, if you specify k=[] and a=[1,2],[2,3],[4,5],[6,7] are added to extend and ordered to np.random.shuffle() The variables are stored as k=[array ([1,2]), array ([2,3]), array ([4,5]), array ([6,7])]. Please tell me how to solve this problem ㅠ<

python array list

2022-09-22 15:42

1 Answers

Something's wrong with the coding.

If you shuffle the list, the type does not change as shown below.

First of all, please upload the code that can be reproduced as soon as it is converted to array.

In [1]: import numpy as np

In [2]: a = [[1,2],[2,3],[4,5],[6,7]]

In [3]: np.random.shuffle(a)

In [4]: a
Out[4]: [[4, 5], [1, 2], [2, 3], [6, 7]]

In [5]: type(a)
Out[5]: list

In [6]: type(a[0])
Out[6]: list


2022-09-22 15:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.