record = ('Dave', 'dave@example', '88-55-1212', '84-55-1212')
name, email, *phone = record
"""
# Use * if you want to unpack N elements from an
# iterable, but the iterable may be longer than N
# elements, causing a “too many values to unpack” exception.
"""
Usually happens with dicts.
hydrogen = {
"name": "Hydrogen",
"atomic_weight": 1.008,
"atomic_number": 1
}
This does not raise an error:
for key, value in hydrogen.items():
print("Key:", key)
print("Value:", str(value))
You have to do hydrogen.items() in order to access the keys and values.
Otherwise it will return an error.