how to convert a string to a matrix in python code example
Example: convert matrix string to matrix python
arr = '[[1, 2], [3, 4], [5, 6]]'
num_set = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]
arr_list = list(arr)
matrix = []
row = []
for i in range(0, len(arr_list)):
try:
if(len(row) == 2):
matrix.append(row)
row = []
if(int(arr_list[i]) in num_set):
row.append(int(arr_list[i]))
except:
continue
print(matrix)