-1

I'm new to Python and coding generally, and I was doing a tiny project and I'm facing a problem:

44, 1, 6
23, 2, 7
49, 2, 3
53, 2, 1
68, 1, 6
71, 2, 7

I just need to remove the 3rd and the 6th character from each line, or more specifically the "," characters from the whole file.

and i need to do it using my python code

for line in my_file:
       ??????????????

Anything helps, thanks.

juanpa.arrivillaga
  • 88,713
  • 10
  • 131
  • 172
user7451333
  • 145
  • 1
  • 2
  • 11

1 Answers1

3

You can replace the character

with open(r'c:\input.txt', 'r') as infile,
     open(r'c:\output.txt', 'w') as outfile:
    data = infile.read()
    data = data.replace(",", "")
    outfile.write(data)

Reference

Community
  • 1
  • 1
iamdeowanshi
  • 1,039
  • 11
  • 19