replace( ) is used to replace or modify or reassign a new character in that string. Let's see a example because an example helps you to keep in mind that topics clearly.
# Here is replace ' ' a space by a hyphen '-'
# and after replacing all ' ' to '-' assign it to that string variable
string = "Python Users Bangladesh"
string = string.replace(' ','-')
print (string)
You can also replace characters from a string using a list. Comming Soon!
# Here is replace ' ' a space by a hyphen '-'
# and after replacing all ' ' to '-' assign it to that string variable
string = "Python Users Bangladesh"
string = string.replace(' ','-')
print (string)
You can also replace characters from a string using a list. Comming Soon!
Comments
Post a Comment