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..

11th Dec 2018, 4:31 PM
Student
Student  - avatar
5 Réponses
+ 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])
11th Dec 2018, 4:38 PM
Fred
+ 6
I think you're searching for str.replace s = 'Abcabc' print(s.replace('a', 'm')) #Abcmbc
11th Dec 2018, 6:10 PM
Mert Yazıcı
Mert Yazıcı - avatar
0
Yes I did that but how I can covert these letters to show the new word?
11th Dec 2018, 4:59 PM
Student
Student  - avatar
0
Why You wan't use str.replace?
12th Dec 2018, 4:32 AM
Fred
- 1
Unfortunately, if statment doesn't do it
11th Dec 2018, 5:06 PM
Student
Student  - avatar