Skip to content

Commit 06c3083

Browse files
committed
setitem
1 parent 700ac17 commit 06c3083

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lists-and-tuples.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ multiple items from another list and remove removes an item.
118118
>>>
119119
```
120120

121+
We can also use slicing and indexing to change the content:
122+
123+
```py
124+
>>> names = ['theelous3', 'LOL', 'RubyPinch', 'go|dfish', 'Nitori']
125+
>>> names[1] = 'wub_wub' # replace LOL with wub_wub
126+
>>> names
127+
['theelous3', 'wub_wub', 'RubyPinch', 'go|dfish', 'Nitori']
128+
>>>
129+
```
130+
121131
As you can see, **list can be changed in-place**. In other
122132
words, they are **mutable**. Integers, floats, strings and many
123133
other built-in types can't, so they are **immutable**.

0 commit comments

Comments
 (0)