Change sublist vs change element of a list
examples/lists/change_sublist.py
fruits = ['orange', 'mango', 'strawberry'] print(fruits[1:2]) # ['mango'] fruits[1:2] = ["banana", "peach"] print(fruits) # ['orange', 'banana', 'peach', 'strawberry']
examples/lists/change_element.py
fruits = ['orange', 'mango', 'strawberry'] print(fruits[1]) # mango fruits[1] = ["banana", "peach"] print(fruits) # ['orange', ['banana', 'peach'], 'strawberry']