Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function, repeat_letters_in_each_word_in(sentence), which takes a Senten

ID: 3867628 • Letter: W

Question

Write a function, repeat_letters_in_each_word_in(sentence), which takes a Sentence of words consisting entirely of letter separated by a single space and ending with a period, and returns a sentence of words separated by a single space and ending with a period, where each word has its letters repeated. Uses repeat_letters_in(word) as a helper function. Sample run: Sentence = 'Brevity is the soul of wit.' print('Original sentence: ', Sentence) print('Sentence with repeat letters in each word: ') print(repeat_letters_in_each_word_in(sentence)) Original sentence: Brevity is the soul of wit. Sentence with repeat letters in each word: Brreeevvvviiiiittttttyyyyyyy iss thheee soouuullll off wiittt. > > >

Explanation / Answer

#!usr/bin/python


def repeat_letters_in_each_word_in(sentence):
    list = sentence.split()
    for i in range(len(list)):
        print(repeat_letters_in(list[i]),end = ' ')
    print()   

def repeat_letters_in(word):
    str = ""
    for i in range(len(word)):
        str1 = word[i]
        if word[i] == '.':
           str = str + '.'
           continue
        for j in range(i):
            str1 = str1 + word[i]
        str = str + str1
    return str

sentence = "Brevity is the soul of wit."
print("original sentence:" + sentence)
print("Sentence with repeat letters in each word:")
repeat_letters_in_each_word_in(sentence)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote