Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

in your guessing game, you replaced dashes in blanks when the user gues…

Question

in your guessing game, you replaced dashes in blanks when the user guessed a correct letter by using string slice. complete the code to replace the character with an index of n with the guessed letter? blanks = blanks:n + letter + ____ blanksn: blanksn+1 blanksn blanksn+1:

Explanation:

Step1: Understand string slicing

To replace a character at index n in a string, we need to take the part of the string before index n, the new character, and the part of the string after index n. The part before index n is blanks[:n], the new character is letter, and the part after index n should be all characters starting from n+1 which is represented as blanks[n+1:] in Python string slicing.

Answer:

D. blanks[n+1:]