jeudi 16 février 2017

For loop does not seem to iterate through every list index (nested if statement)

I am trying to write a code which will turn a word into pig latin/dog latin. For example, is will become isyay, scram will become amscray. The first situation works, however, the second situation prints cramsay. Why does it not seem to be looping properly?

def doggify(word):
    wordlist=list(word)
    start=word[0]
    if start=='a' and start=='e' and start=='i' and start=='o' and start=='u':
       dogword=word+'yay'
       return print(dogword)
    else:
       empty=[]
        for letter in wordlist:
            if letter!='a' and letter!='e' and letter!='i' and letter!='o' and letter!='u':
            empty.append(letter)
            wordlist.remove(letter)
            dogword=''.join(wordlist)+''.join(empty)+'ay'
            return print(dogword)

Aucun commentaire:

Enregistrer un commentaire