I have done the following snippet, a list where I went line by line and replaced the dots with commas, however in the end the list remains the same since only the line variable changes. How to update the list with the replaced values?
for line in mylist:
line=line.replace('.',',')
line=line.replace('a','b')
I am looking for a quick pythonic solution, other than using a 2nd list to save the replaced value. I'd like to use only 1 list, if possible and "update" it on the go.
I have multiple operations inside the for
, for example in the way edited above, making the list update from the for is not possible as a "1 liner" like it's commonly done. I was looking for some sort of other way to update it if possible.