# # Pig Latin # # Take word and convert it to pig latin def convert_word(word): word = word.lower() first_letter = word[0] # if first letter of word is a vowel if first_letter in['a', 'e', 'i', 'o', 'u']: return word + 'way' elif first_letter in ['fl']: return word[2:] + word[0:] +'ay' #if first letter is consonant #move letter to end and append 'ay' else: return word[1:] + first_letter + 'ay' # Input words and convert them to_convert = raw_input("Enter a phrase to convert") # Split words into word word_list = to_convert.split() # Iterate over word list and convert each one for word in word_list: print convert_word(word), print
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