I'm attempting to create a pig-latin translation program. It is part of the 100 projects on GitHub I am working through. I do not like to check solutions before I have given it a real effort.
Here is the code I have at the moment, and it does complete the translation, the problem though is that it outputs the translation with some unsightly quotes around the replaced letter.
words = raw_input("Enter some text to translate to pig latin: ")
print "You entered: ", words
#Now I need to break apart the words into a list
words = words.split(' ')
#Now words is a list, so I can manipulate each one using a loop
for i in words:
if len(i) >= 3: #I only want to translate words greater than 3 characters
i = i + "%ray" % (i[0]) #The magical translator!
i = i[1:] #I want to print the translation, but without the first letter
print i.strip("'")
When I run this program I get this result:
You entered: hello world
ello'h'ay
orld'w'ay
I don't know how to strip the quotations out of my translated words. I think I'll use a .join command next to recreate the translated sentence, but I'm at a roadblock right now.
I have tried:
i = i.strip("'")
but that did not work either. Thanks!