1
QuizMultiple Choice

Creating a Game

Question 1 • SC-Fundamentals of Computing - Content Recovery - Design & Development

In your guessing game, you replaced dashes in blanks when the user guessed a correct letter by using a string slice. Complete the code to replace the character with an index of n with the guessed letter? blanks = blanks[:n] + letter + _____

Answer
A
blanks[n+1:]
B
blanks[n]
C
blanks[n+1]
D
blanks[n:]

Explanation

The slice `blanks[:n]` keeps all characters before index `n`. After inserting the guessed `letter`, the next slice must keep the characters after index `n`, starting at `n+1`, so the completed expression is `blanks[:n] + letter + blanks[n+1:]`. Choice A gives that slice.

AI-written and checked against the verified answer.

Next