I have this array "m":
m = ['0000', '0001', '0010', '0011', '1111']
How could I use a lambda function to change its format to:
n1 = [0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1,1,1,1,1]
or to:
n2 = [[0,0,0,0],[0,0,0,1],[0,0,1,0],[0,0,1,1],[1,1,1,1]]
?
[int(x) for x in '12345']will get you the inner array.n2 = [[int(char_i) for char_i in char] for char in m]n0 = [list(item) for item in m]; n1 = [int(i) for lst in n0 for i in lst]; n2 = [[int(i) for i in lst] for lst in n0]