Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

remove a char in a string python

s = "aabbcadcba"

print(s.replace("a", "", 1) # removes only one "a" from the string.
out -> abbcadcba

print(s.replace("a", "") # removes all the "a"s from the string.
out -> bbcdcb
Source by www.journaldev.com #
 
PREVIOUS NEXT
Tagged: #remove #char #string #python
ADD COMMENT
Topic
Name
3+4 =