I am trying to take a file and translate each line into ‘pseudo’ pig latin (just moving the first letter and adding ay).
I have created a loop that works, but it only works on the first line from the file. It does not return to finish going through the file.
So the loop is working to go through each word to translate it to pig latin, I just cant get it to go back to the original list to translate every line.
Example of the txt file:
Use the Force Luke
Have a nice day
Don't call me Shirley
My code is only giving me:
English: use the force luke
Pig Latin: seuay hetay orcefay ukelay
It is not moving to the second line from the txt file.
with open('phrases.txt', 'r') as text:
file_contents = text.readline().rstrip()
fullRun = []
for i in file_contents.split():
latin = i[0]
pig = i[1:]
fullRun.append(pig+latin+'AY')
x = ' '
s = x.join(fullRun)
print(f'English: {file_contents}')
print(f'Pig Latin: {s}')
Fred Johnson is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3