Python String Programs

Design a program to take a word as an input, and then encode it into Pig Latin. A Pig Latin is an encrypted word in English, which is generated by doing the following alterations:
The first vowel occurring in the input word is placed at the start of the new word along with the remaining alphabet of it. The alphabet is present before the first vowel is shifted, at the end of the new word it is followed by “ay”

s = input("Enter a word:")
k=-1
for i in s:
    if i in "AaEeIiOoUu":
        k=s.index(i)
        break
r=""
if k!=-1:
    r=s[k:]+s[:k]+"ay"
else:
    r=s+"ay"

print("Piglatin equivalent is",r.capitalize())

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top