A comment list where only the loop variable changed

Code review · Medium · §10.4 Index and value together

This code is meant to change the original list by replacing each empty comment with "(deleted)". It runs without an error, but the list stays the same. Fix just one line.

Code to fix

comments = ["nice", "", "the best", ""]
for i, c in enumerate(comments):
    if c == "":
        c = "(deleted)"
print(comments)

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.