I'm trying to make a Pig Latin translator, but ran into some trouble when testing if the first letter is a vowel. I did some googling and found a way to solve it, but I wanted to know why one work and the other doesn't. Here is my code (the commented section is the part that doesn't work):
word = raw_input("Input a word: ").lower()
vowels = {'a', 'e', 'i', 'o', 'u'}
if len(word) > 0 and type(word) == str:
#if word[0] == ('a' or 'e' or 'i' or 'o' or 'u'):
# pigWord = word + 'ay'
# print pigWord
if word[0] in vowels:
pigWord = word + 'ay'
print pigWord
else:
pigWord = word + word[0] + 'ay'
print pigWord[1:]
else:
print 'Please enter a valid word.'
It seems that when I use the first method (the commemted section) it only tests if the first letter is an "a", if not it goes to "else:".