+ 1

How to remove a letter from a string?

Taking into account there are other letters that are the same as that one. Edit: And without a specific letter? Like you want to remove the 2nd letter (with same conditions as before)

8th Jan 2019, 3:00 PM
Ric2908
Ric2908 - avatar
3 Antworten
+ 3
s = 'some string' n = 1 # second character print(s[:n] + s[n+1:])
8th Jan 2019, 4:37 PM
Rugved Modak
Rugved Modak - avatar
+ 5
s = 'letter' print(s.replace('e', '', 1)) # output: An error occurred. Please check your internet connection and try again.
8th Jan 2019, 3:16 PM
Anna
Anna - avatar
+ 1
😂😂😂
8th Jan 2019, 5:08 PM
HonFu
HonFu - avatar