s = "hello" s[1:4] = "ELL" # TypeError: 'str' object does not support item assignment
s = s[:1] + "ELL" + s[4:] print(s) # hELLo
lst = list("hello") lst[1:4] = "ELL" # 把 1~3 号位置换成 'E','L','L' print(''.join(lst)) # hELLo