Python gradebook project

So in the python grade book project https://www.codecademy.com/courses/learn-python-3/projects/gradebook we use the code gradebook.append((‘visual arts’, 93)) . Why is it that we are allowed to add multiple items via append in this case?

1 Like

A good query. What you’re actually appending there is a tuple ('visual arts', 93). It’s a single object reference so it can be added with append. Tuples are similar to lists but you can’t change the references stored in the tuple (no reordering or appending/removing). The tuple is immutable (but the objects it references aren’t necessarily immutable themselves).

You can find a little more info on them here-
https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences

1 Like