Python change one letter in word? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python change one letter in word?

Hi I want to change live in love. What possibilities do I have?

19th Sep 2017, 5:04 AM
Thomas Nauta
Thomas Nauta - avatar
5 Answers
+ 3
hi, str = 'live' print(str) str = str[:1] + 'o' + str[2:] print(str)
19th Sep 2017, 5:49 AM
MBZH31
MBZH31 - avatar
+ 5
Lmao why so many people type python as phyton!? There's a str.replace(original,final) method
19th Sep 2017, 8:47 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
You could split the word into an array, iterate over it and change the letter. Then change it back to a string. There's also the built-in method replace() but I don't know how it does it.
19th Sep 2017, 5:12 AM
spcan
spcan - avatar
0
Thanks guys, Jeah the python was recommended by Android. 😁
19th Sep 2017, 9:13 AM
Thomas Nauta
Thomas Nauta - avatar