I am trying to write a program in Python that converts user input from English to Pig Latin ("Y" is not a vowel in this case, breaks off at first vowel and moves preceding consonants to the end). The end product of my program should be able to compute whole sentences, but right now im just trying to get it to do one word. This is what I currently have but whenever a string is inputted that does not begin with a vowel it goes through and performs the function for every instance of a vowel. For example:
Enter a word:hello
defining variables to be used later on
pyg = 'ay'
vowels = "aeiou"
get user input
original = raw_input('Enter a word:')
# make sure only alphabetic word is entered if len(original) > 0 and original.isalpha(): word = original.lower() # change to lower case input for word in original.split(): if word in vowels: # find if first letter is vowel new_word = word + pyg print new_word else: for i in range(1, len(word)): # search word for first instance of vowel if word[i] in vowels: # splice word so that the consonants preceding the first vowel move to the end new_word = word[i:] + word[:i] + pyg print new_word else: # if input is not alphabetic print 'That is not a word!'