Functions | Sololearn: Learn to code for FREE!



I am trying to write a python program that ask use user to write a word with only four letters (A, D, I, R) then read the word and convert the letters A=M, D=N, I=A, R=B finally display the converted word... I define 3 functions but I don't know how to convert the letters in word..

12/11/2018 4:31:51 PM


5 Answers

New Answer


Imagine that String is list of chars. You can find letter with help of index. For example try this code: string = 'word' for i in range (len(string)): print (string[i])


I think you're searching for str.replace s = 'Abcabc' print(s.replace('a', 'm')) #Abcmbc


Yes I did that but how I can covert these letters to show the new word?


Why You wan't use str.replace?


Unfortunately, if statment doesn't do it