How to replace multiple characters in a string using python?
As you may already know there is a method for string called
But what if you want to replace both
Here output would be
#python #string #replace #multiple_replacement
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