+ 7

Removing characters from strings

Does any one know how I can remove specific characters from a string in python? Example: word = str(input()) # Entered word is “Code” How can I remove a specific character like ‘e’ from the string?

7th May 2020, 5:11 PM
Edilson Zau
Edilson Zau - avatar
7 Antworten
+ 2
Word = word.replace("a","b") On first argument (a) written word/letter what do you want replace to other word/letter. On second argument (b) written word/letter for which do you want replace a first (a) argument. You can leave empty second argument, if you want delete any object from the string. Example: string = "hello world" #I want to delete space in center of #hello/world string = string.replace(" ","")
7th May 2020, 5:51 PM
_nrkvv_
_nrkvv_ - avatar
+ 4
Word = word.replace("e", "")
7th May 2020, 5:14 PM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 4
Eliya Ben Baruch thanks alot 😁
7th May 2020, 5:18 PM
Edilson Zau
Edilson Zau - avatar
+ 3
_nrkvv_ Thank you 😄
7th May 2020, 5:56 PM
Edilson Zau
Edilson Zau - avatar
+ 2
Oh, Sinro on profile picture. Nice
7th May 2020, 5:53 PM
_nrkvv_
_nrkvv_ - avatar
+ 1
You are welcome
7th May 2020, 5:19 PM
Eliya Ben Baruch
Eliya Ben Baruch - avatar