it is a translator program , can anyone explain me how the letters are replaced by the for loop and if statement ??
translation = ""
for letter in ph:
if letter in "AEIOUaeiou":
translation = translation + "N"
translation = translation + letter
print(trans(input("enter a word : ")))
Expecting your answer :) Thank you
It's not as complicated as it looks like. The input string is iterated in a for loop. All vowels will be replaced by *N*, all the rest will keep as input.
enter a word : aeiouAEIOU # input
NNNNNNNNNN # output
enter a word : bcdfghBCDFGH # input
Naveen Kumar, i forgot to mention, that there is a real function in python (translate()) that can do a translation with characters and a predefined dict. Here a sample :
Naveen, think of translation as a building block variable. Its value starts as the empty string "" and each translation = translation + ? adds the defined letter the string (building block).
Hope that helps!