How can I correctly replace values in a list using Python without encountering a TypeError

welcome to shbcf.ru