0
Functions
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..
5 Respostas
+ 1
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])
+ 6
I think you're searching for str.replace
s = 'Abcabc'
print(s.replace('a', 'm')) #Abcmbc
0
Yes I did that but how I can covert these letters to show the new word?
0
Why You wan't use str.replace?
- 1
Unfortunately, if statment doesn't do it