In Python, I have this list:
[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1), (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
and I want to convert it into a list of strings, like:
['000', '001', '010', '011', '100', '101', '110', '111']
This was my attempt:
val = [0,1]
['{x}{y}{z}'.format(x=x,y=y,z=z) for x in val for y in val for z in val]
But in some cases, the length of the string e.g.'001' may be variable (e.g. '01101') so it is frustrating editing this part '{x}{y}{z}'.format(x=x,y=y,z=z) each time
How can I do that?