+ 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?

23rd Jul 2019, 2:09 PM
Alix Carmo
Alix Carmo - avatar
2 Respuestas
+ 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
23rd Jul 2019, 2:25 PM
Lothar
Lothar - avatar
+ 1
Lothar thanks!!!
24th Jul 2019, 5:41 PM
Alix Carmo
Alix Carmo - avatar