Python Forum

Full Version: Uppercase problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I've been learning python for a week and today i started doing a translator in an invented language. The problem is that if i write an upper letter, it is translated as a lower letter.
Here is the code



def translate(phrase):
    translation = ""
    for letter in phrase:
        if letter.lower() in "aeiou":
            if letter.isupper():
                translation = translation + "G"
            else:
                translation = translation + "g"
        else:
            translation = translation + letter
    return translation


print(translate(input("Enter a phrase")))
def translate(phrase):
    translation = ""
    for letter in phrase:
        if letter.lower() in "aeiou": # if letter is lower
            if letter.isupper(): # this can never be true, in order to get here, letter must have been a vowel and lower case!
Ok,
So I should remove the lower fuction.
Sorry for asking again but it’s my first week coding and I amb kind of a noob.
Actually, my previous post was incorrect.
the letter upper letter is lowered in scope for the if statement only. if letter.lower() in "aeiou":
your code works:
[inline]Enter a phrase Everyone
Gvgrygng[/inline]
Ok,
Thanks a lot