Jed Rembold
February 6, 2026

s = "DANGERBOTTLECHANCEBRIGHT""BANANA" with
s[6] + s[1:3] + s[-10:-8] + s[1] for 6
pointsConsider the starting string
s = " --- ERROR_USER: jAnE.dOe@mAiL_sErVeR.CoM !!! "Your task is to systematically clean up and transform that string into something that just looks like
s = "jane.doe@mailserver.com"
using introduced string methods, slicing, and variable assignment.
english.py Libraryenglish module
english module exports two
resources:
ENGLISH_WORDS: a constant sequence which
contains all the valid English words in alphabetical order and lowercase
formatis_english_word(): a predicate function
which takes a string as input and returns
True or False
depending on if that string is a valid English wordENGLISH_WORDS is a sequence!
So you can loop directly over it to get each word one at a timefleet ⟶ eetflay
orange ⟶
orangeway
from english import ENGLISH_WORDS, is_english_word
def find_first_vowel(word):
"""
Finds the first vowel index in a string
Algorithm:
Loop through all letters
Check if that letter is in aeiou
If it is, immediately return the index
"""
for i in range(len(word)):
if word[i].lower() in "aeiou":
return i
return -1
def pig_latin(word):
"""
Converts a word to its Pig Latin form
Algorithm:
Check the first letter to see if vowel
Task 1 if is not vowel
Figure out where first vowel is
Slice and rearrange
Task 2
Concatenate on a way
"""
first_vowel = find_first_vowel(word)
if first_vowel == 0:
# Easy tack on way
word += "way"
elif first_vowel > 0:
# Find first vowel and rearrange
first_part = word[:first_vowel]
second_part = word[first_vowel:]
word = second_part + first_part + "ay"
return word
if __name__ == '__main__':
for word in ENGLISH_WORDS:
platin = pig_latin(word)
if is_english_word(platin) and word != platin:
print(word, platin))