Skip to content

Instantly share code, notes, and snippets.

@jarhill0
Forked from idatarbell/pyglatin single sentence
Last active February 16, 2017 19:03
Show Gist options
  • Save jarhill0/88849142fab993c7a4e5b4cde46fecba to your computer and use it in GitHub Desktop.
Save jarhill0/88849142fab993c7a4e5b4cde46fecba to your computer and use it in GitHub Desktop.
def pyg_sentence(sentence):
new_sentence = ""
for word in sentence:
new_sentence += pyg(word)
return new_sentence
def pyg(x):
if x[0] == 'a' or x[0] == 'e' or x[0] == 'i' or x[0] == 'o' or x[0] == 'u':
new_word = ' ' + x + "ay"
elif x[1] != 'a' and x[1] != 'e' and x[1] != 'i' and x[1] != 'o' and x[1] != 'u':
stem = ' ' + x[2:]
beg = x[0:2]
new_word = stem + beg + "ay"
else:
stem = ' ' + x[1:]
beg = x[0]
new_word = stem + beg + "ay"
return new_word
raw_sentence = input("enter a sentence:")
Sentence = raw_sentence.split()
print(pyg_sentence(Sentence))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment