I'm having a little bit trouble with file operations.. I want to manipulate data 2 times and write the last manipulated data into same file.
This is my manipulated file:
['Simon', 93.45000000000002, 'AA']
['Jane', 87.55000000000001, 'BA']
['Peter', 85.95, 'BA']
And here is my code for how to change data in file.
for line in manipulated_file:
line=line.split()
list_to_be_written=[]
for i in line:
i=i.replace("['","")
i=i.replace("'","")
i=i.replace(",",":")
i=i.replace("]","")
list_to_be_written.append(i)
list_to_be_written=" ".join(list_to_be_written)
print list_to_be_written
It runs perfecly how ever i can't write the output to the file..
Expected output in the same file:
Simon: 93.45000000000002: AA
Jane: 87.55000000000001: BA
Peter: 85.95: BA
Thank you in advance.