All right, it's time to wrap things up! Let's have a quick summary of what we've learned before we move on:
- Tuples are frequently used to return multiple values from a function.
return (min, max)
- Tuples as function result types are often unpacked into multiple variables.
list_min, list_max = get_min_max(user_list)
- Use underscores to ignore certain values.
_, list_max = get_min_max(user_list)
- Tuples often represent real-world objects ...
person = ('Mark', 28, 'Spanish')
- ... or certain states/positions.
x_y_coordinates = (5, -14)
- Tuples are often used in conjunction with lists.
people = [
('Mark', 28, 'Spanish'),
('Miranda', 21, 'ZEA')
- To compare two lists element by element, we can use the
for pair in zip(list_1, list_2):
if pair == pair:
Ok! How about a short quiz now?