more info: [data structures tutorial - tuples and sequences](https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences)
## 3
We said that lists can also be used for unpacking. Let us see some examples:
```py
x=[1,2,3]
print(x)
# outputs the list: `[1, 2, 3]`
print(*x)
# outputs print(x[0], x[1], x[2]): `1 2 3`
```
## 4
What about other containers?
```py
d={1:'a',2:'b',3:'c'}
x,y,z=d
print(x)# outputs `1`
print(*d)# outputs `1 2 3`
s={1,2,3}
x,y,z=s
print(x)# outputs `1`
print(*s)# outputs `1 2 3`
```
Nice!
##
<!-- editing does not work on tuples, tuples can be defined w/o parantheses -->
...
...
@@ -543,7 +573,7 @@ d = {'Mounika' : 'LSI',
'Sriraam':'MCS'}
```
A) the names in `d` are the keys of key-value pairs
A) the forenames in `d` are the keys of `d`
A) every key in a dict is unique
A) values can be of every datatype
A) keys can be of every datatype
...
...
@@ -551,8 +581,13 @@ A) I don't know
. . .
Python generates a hash, i.e., a unique number, out of each key which is not allowed to change during the lifetime of a dict. Therefore keys must not be immutable.
Python generates a hash (a unique number) out of each key which is not allowed to change during the lifetime of a dict. Therefore keys must be immutable.
Why can we only use immutable items? Couldn't we create a hash out of a `list`?
It is possible but then we would have to calculate the hash everytime we use the list as a key. You would had to pay attention that the list never changes. A better way is to not allow it at all by using for example `tuple`s.
Practically Python does not allow this [by looking for a method called `__hash__` to see if an object can be used as a key](https://stackoverflow.com/a/25193267).
##
<!-- similarity between dict and set -->
...
...
@@ -633,8 +668,8 @@ Which code deletes all characters which belong to the house Gryffindor?