I am trying to manipulate an array and perform operations. My input is an array
a= [['f' '0' '1' '0' '1' '0']
['o' '0' '0' '1' '0' '0']
['o' '0' '1' '0' '1' '1']
['!b' '1' '0' '1' '0' '0']
['a' '0' '0' '1' '0' '0']
['r' '0' '1' '0' '1' '1']]
If I take the first row, my output should just be the columns in which 1 is present. Similarly, I do for each row and get output. So my output should be an array.
output = [['f' '1' '1'
'o' '0' '0'
'o' '1' '1'
'!b' '0' '0'
'a' '0' '0'
'r' '1' '1' ]
['f' '0'
'o' '1'
'o' '0'
'!b' '1'
'a' '1'
'r' '0' ]
['f' '1' '1' '0'
'o' '0' '0' '0'
'o' '1' '1' '1'
'!b' '0' '0' '0'
'a' '0' '0' '0'
'r' '1' '1' '1']
['f' '0' '0'
'o' '0' '1'
'o' '0' '0'
'!b' '1' '1'
'a' '0' '1'
'r' '0' '0' ]
['f' '0'
'o' '1'
'o' '0'
'!b' '1'
'a' '1'
'r' '0' ]
['f' '1' '1' '0'
'o' '0' '0' '0'
'o' '1' '1' '1'
'!b' '0' '0' '0'
'a' '0' '0' '0'
'r' '1' '1' '1']]
Here's my Code
output = []
for i in a:
for j in i:
if j == 1:
output = a[0:]
output.append([n][j]) for n in len(i)
else:
pass
1in this row.