HomeBlogReplacing a variable in a list using a for-loop? [duplicate] in python ?Problem and SolutionsReplacing a variable in a list using a for-loop? [duplicate] in python ?By M.K. Verma · 3 May 2022In your exampe i is an item in list, not an index: cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10] for i, val in enumerate(cards): if val == 11: cards[i] = 1 print(cards)Share this:CommentsLeave a commentPost