+ 4
string.Replace in python
how are the rules for "abbbbbbbba".replace("bbbbb","cccccc") what to do if the middle is to be replaced?
7 Respostas
+ 9
s="The dog is large small"
ss=s.replace(s.split()[3],s.split()[3]+'ly')
ss 'The dog is largely small'
you can do like this
+ 4
I don't understand!
+ 4
@brains The string contains 7b's . How to call rhe statement replace, if the middle 5 b's are to be replaced?
+ 4
I read the doc, but this case is not handled.
+ 1
you can use an auxiliar list to save the values that has to be the sames,then replace the rest and finally concatenate.
something like this:
aux='a'
new=replace('old','new')
aux2='a'
final=aux+new+aux2
+ 1
yaaa