generate functionSat, 12 Nov 2022

A function that accepts english text and converts it to similar text in pig latin

def pig_latin(text): say = "" # Separate the text into words words = text.split() for word in words: # Create the pig latin word and add it to the list say += word[1:] + word[0] + "ay " # Turn the list back into a phrase return say pig_latin("hello how are you") # Should be "ellohay owhay reaay ouyay" pig_latin("programming in python is fun") # Should be "rogrammingpay niay ythonpay siay unfay"

Questions about programming?Chat with your personal AI assistant