0

I have the txt file below and I want the remove the "+" if there is a + in front of the number.

+905061459318

+905458507534

+905437335094

I have tried almost all of the solutions that exist in Stackoverflow but still, I cannot remove the + from the line.

The code is here.

with open("numbers.txt") as f:
lines = [line.rstrip('\n') for line in open("numbers.txt")]
for line in lines:
    if line.startswith("+"):
        line.replace("+","")
    else:
        pass
Community
  • 1
  • 1
Resul Bulbul
  • 45
  • 1
  • 10

1 Answers1

2

You already have line.rstrip('\n'). Make that line.rstrip('\n').lstrip('+').

orlp
  • 112,504
  • 36
  • 218
  • 315