#pyg is set to 'ay' pyg = 'ay' #setting the inputed word as the value for original original = raw_input('Please enter a word >') #checking to see if word if has more than zero characters and that all characters are letters if len(original) > 0 and original.isalpha(): word = original.lower() #changing all letters to lowercase first = word[0] #setting first to the first letter of the lowercase word #checking to see if the first letter is a vowel (aeiou) if first == 'a' or first == 'e' or first == 'i' or first == 'o' or first == 'u': new_word = word + pyg #combining the vowel word and 'ay' suffix print new_word #if first letter is not a vowel it is pushed here else: new_word = word[1:] + first + pyg #combining the remainder of word after first letter is removed with the first letter added to the end and the suffix 'ay' follows print new_word else: print 'empty'
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question