+ 1
Change text
Hey guys! Imagine you have one code that prints for example (absdhebabaaaa) And i want to print change all "a", how can i do it? And for words how can i do it?
2 Antworten
+ 9
You can do it with replace(). It will replace all 'a' to 'x' in sample code.
txt = 'absdhebabaaaa'
new_txt = txt.replace('a', 'x')
print(new_txt)
# ouput: xbsdhebxbxxxx
+ 1
Lothar thanks!!!