file = open('english.txt','r')
vowels = ('a', 'e', 'i', 'o', 'u')
for text in file:
translated= []
lines = text.split()
print(' '.join(lines))
print("Translated to pig latin becomes:")
for words in lines:
if words[0] in vowels:
words = words + 'yay'
else:
while words[0] not in vowels:
words = words[1:] + words[0]
words = words + 'ay'
translated.append(words)
words = ' '.join(translated)
print(words, '\n')
私が得ている結果は次のとおりです。
this is a statement
Translated to pig latin becomes:
isthay isyay ayay atementstay
its going through python
Translated to pig latin becomes:
itsyay oinggay oughthray onpythay
and this is the result
Translated to pig latin becomes:
andyay isthay isyay ethay esultray
the end
Translated to pig latin becomes:
ethay endyay
スタンザごとに 1 行目と 3 行目に引用符を付けたいと思います。たとえば、「終わり」「エセイ エンディエイ」
ありがとう!