I need to take a list, multiply every item by 4 and separate them by coma.
My code is:
conc = ['0.05 ml : 25 ml', '0.05 ml : 37.5 ml', '0.05 ml : 50 ml', '0.05 ml : 62.5 ml', '0.05 ml : 75 ml']
new_conc = [", ".join(i*4) for i in conc]
print(new_conc)
But when I run it, I get every SYMBOL separated by come. What I need is multiplied number of shown EXPRESSIONS separated by coma.
So the output should be:
['0.05 ml : 25 ml', '0.05 ml : 25 ml', '0.05 ml : 25 ml', '0.05 ml : 25 ml', '0.05 ml : 37.5 ml', '0.05 ml : 37.5 ml', '0.05 ml : 37.5 ml', '0.05 ml : 37.5 ml', '0.05 ml : 50 ml', '0.05 ml : 50 ml', '0.05 ml : 50 ml', '0.05 ml : 50 ml', '0.05 ml : 62.5 ml', '0.05 ml : 62.5 ml', '0.05 ml : 62.5 ml', '0.05 ml : 62.5 ml', '0.05 ml : 75 ml', '0.05 ml : 75 ml', '0.05 ml : 75 ml', '0.05 ml : 75 ml']
I found this answered question, but as I already mentioned, I get separate symbols, separated by coma.
You can use a simple for
loop.
new_conc = []
for item in conc:
new_conc.extend([item] * 4)