Skip to content

Program to convert a given string to Pig Latin #9712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Oct 5, 2023
17 changes: 17 additions & 0 deletions strings/pig_latin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def pig_latin(sentence):
sentence = sentence.lower()
length = len(sentence)
if sentence[0] in "aeiou":
result = sentence + "way"
else:
for i in range(length):
if sentence[i] in "aeiou":
break
result = sentence[i:] + sentence[:i] + "ay"
return result


statement = input("Enter a string: ")
answer = pig_latin(statement)

print(f"The PIG LATIN of the entered string is \"{answer}\"")