Skip to content

Commit 8397433

Browse files
Create PygToEng.py
1 parent c068db2 commit 8397433

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

PygToEng.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#Randall Hall
2+
#A Python program to translate Pig Latin to English while ignoring words that are not in Pig Latin
3+
4+
#Pig Latin --> English
5+
6+
sentence = input('Enter a sentence in Pig Latin: ')
7+
word = sentence.split()
8+
word_count = len(word)
9+
10+
print("There are %s words in this sentence" % (word_count))
11+
12+
vowel = 'a', 'e', 'i', 'o', 'u'
13+
pcg = 'ay'
14+
pvg = 'way'
15+
16+
for word in sentence.split():
17+
18+
if pvg in word and word != pvg:
19+
new_word2 = word[0:-3]
20+
print ("%s --> %s" % (word, new_word2))
21+
22+
elif pcg in word and word != pcg:
23+
new_word = word[0:-3]
24+
first = word[-3]
25+
new_word = first + new_word
26+
print ("%s --> %s" % (word, new_word))

0 commit comments

Comments
 (0)