I am learning python and in the course, I had to make a translator that transforms vowels into the letter "g".
In the program, I had to check if the phrase to be translated had any uppercase vowels in order to replace them with a capital letter "G".
And I fail to understand why .lower()
doesn't apply for the rest of the code? In my thinking, if I apply letter.lower()
in the next line the value of the variable letter
should still be in lowercase. Here is my code:
def translate(phrase):
translated = ""
for letter in phrase:
if letter.lower() in "aeouiy":
if letter.isupper():
translated = translated + "G"
else:
translated = translated + "g"
else:
translated = translated + letter
return translated
print(translate(input("enter phrase to translate into giraffe elegant language: ")))