Find the first vowel in the English word, take the consonant(s) preceding that vowel, and move them to the end of the word, followed by “ay”.
If the first letter of the word is a vowel, then just add “ay” to the end.
Treat “Y” as a consonant.
For words with no vowels besides “Y” such as “my”, just print out the original word.
The capitalization should be preserved (assume that only the first letter of any word might be capitalized).
You can assume that the string has only letters and spaces with no punctuation.
So I came up with something that works for words that start with a vowel and words that don't. However, I can't seem to figure out how to print just the original word if no vowels were in that word. I also can't figure out how to have the program work properly if more than one word is entered. I've been messing around with the .split function. I'm guessing I would have to have a for loop that goes through the string and gets each word, append each of those words into a list, and then have another for loop that does the translating on each word?
Here's what I have so far, and thanks in advance for any help!
VOWELS = ("a", "e", "i", "o", "u", "A", "E", "I", "O", "U")
def main():
word = raw_input("Please enter a word: ")
if word[0] in VOWELS:
print word + "ay"
else:
print word[1:] + word[0] +"ay"
main()

New Topic/Question
Reply



MultiQuote




|