Tech C**P
15 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
How to replace multiple characters in a string using python?

As you may already know there is a method for string called replace that replaces 1 character with a new given character:
'+98 21 445 54 12'.replace('+', '')
# output is 98 21 445 54 12

But what if you want to replace both + and [SPACE] inside of the string? The answer is simple just chain the methods:
'+98 21 445 54 12'.replace('+', '').replace(' ', '')

Here output would be 98214455412.

#python #string #replace #multiple_replacement