well first of all i cant figure out how to move the first letter to the end
but before i fix that i need help figuring out why the else branch is being totally ignored. even when the conditions are met for else It still gives me the result in the if branch

pyg = 'ay'

original = raw_input('Enter a word')
word=original
first=word[0]
new_word=original[1:]

if len(original) > 0 and original.isalpha():
    if first == "a" or "e" or "i" or "o" or "u":  
        print original+pyg
    else:
        new_word=original[1:]
        print new_word
else:
    print 'empty'
word=original
first=word[0]

Edited 3 Years Ago by toniann.midori

The reason it isn't working is because the condition in the if: statement is incorrect. When you write

    if first == "a" or "e" or "i" or "o" or "u": 

... what it is really saying is

        if (first == "a") or ("e") or ("i") or ("o") or ("u"):

That is to say, it only compares the value of first to "a"; the rest of the clauses all evaluate to True, so the the whole condition will always be True.

In order to compare a single value against several values, you need to use a list and a set membership (in or not in) operator:

    if first in ["a", "e", "i", "o", "u"]:

Note that you also aren't handling the case of uppercase values, but that's a complication you can handle on your own, I think.

Edited 3 Years Ago by Schol-R-LEA

Thank you, your solution worked :D
oh i didnt notice i didnt hadle the upper case values, thanks for pointing that out too :)

Edited 3 Years Ago by toniann.midori

This question has already been answered. Start a new discussion instead.