Created
June 27, 2021 06:32
-
-
Save 01aleem/d097fb04a0a16aceb01fad8685b60244 to your computer and use it in GitHub Desktop.
A secret language that adds yay to words starting with a vowel and 'ay' to words starting with consonants after moving the first consonnant cluster of the word to the end of the word.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get sentence from the user | |
# split sentence into words | |
# loop through words and convert into a special latin | |
# if word starts with vowel, just add 'yay' | |
# otherwise, move the first consonant cluster to the end and add 'ay' | |
# stick the words back together | |
# output the final string | |
original = input('Please enter a sentence: ').strip().lower() | |
words = original.split() | |
new_words = [] | |
for word in words: | |
if word[0] in 'aeiou': | |
new_word = word + 'yay' | |
new_words.append(new_word) | |
else: | |
vowel_pos = 0 | |
for letter in word: | |
if letter not in 'aeiou': | |
vowel_pos = vowel_pos + 1 | |
else: | |
break | |
cons = word[:vowel_pos] # be careful about the indentation here, it should be in the else statement (else: vowel_pos... and not in the subsequent for loop (for letter..) | |
the_rest = word[vowel_pos:] | |
new_word = the_rest + cons + 'ay' | |
new_words.append(new_word) | |
output = ' '.join(new_words) | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment