This an example of a possible list with the sublists:
rows = [[1, 1, 'x'], [1, 'x', 1], [1, 1, 'x'], [1, 'x', 1], ['x', 1, 1], ['x', 1, 1]]
I am looking for an efficient way to replace 'x' either by 0 or 1 in the sublists. The sublists has no fixed sized or number. I mean, it could be a list like this one:
[(1, 1, 'x', 'x'), (1, 1, 'x', 'x'), (1, 'x', 1, 'x'), (1, 'x', 'x', 1)]
I tried this:
for row in rows:
for pos in row:
if pos == 'x':
pos.replace('x','0')
Even knowning that I need '0' as an integer, just to print an output. But rows kept the 'x' unchanged.
Any suggestions?
replacereturns a new string