vendredi 23 août 2019

my code keeps showing syntax error in my elif/else statements

I'm trying to make a basic pig latin translator but the editor keeps showing me a syntax error.

ay = "ay"

way = "way"

consonants = ("b", "c", "d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "y", "z")

vowels = ("a", "e", "i", "o", "u")

user_word = input("Enter your word here: ")

first_letter = user_word[0]

first_letter = str(first_letter)

first_letter = first_letter.upper()

if first_letter in consonants:

        print(first_letter + "is a consonant.")

remove_first_letter = user_word[1:]

pig_latin = remove_first_letter + first_letter + ay

print("The word in Pig Latin is " + pig_latin)

elif first_letter in vowels:

        print(first_letter + "is a vowel.")

pig_latin = user_word + way

print("The word in Pig Latin is " + pig_latin)

else:

        print("I don\'t know what" + first_letter + "is.")

This is what i have come up with. The exact error message that it shows is:

File "<ipython-input-33-8e1536233f19>", line 14

    elif first_letter in vowels:

       ^

SyntaxError: invalid syntax

Aucun commentaire:

Enregistrer un commentaire