word="somebigword" list(word) word[4:7]=list("small")I get an error as below. Why does this happen, even though the String has been converted as a list in line 2.
Traceback (most recent call last): File "<pyshell#19>", line 1, in <module> word[4:7]=list('small') TypeError: 'str' object does not support item assignmentHowever, if i do the following, it works fine. I want to understand the error in the previous case.
word=list("somebigword") list(word) word[4:7]=list("small")The output is ['s', 'o', 'm', 'e', 's', 'm', 'a', 'l', 'l', 'w', 'o', 'r', 'd']