Methods
There will be times when you need to add values into a list, or update values in a dictionary. Here we will see some of the object-oriented nature of Python, which is different from R.
Everything in Python is an object (e.g., list object, dictionary object, etc). Objects can all perform certain tasks (e.g., add values to a list, update values in a dictionary). Instead of calling functions on the object you want to manipulate, you use dot notation to have the object perform an action on itself by calling a method.
This exercise is part of the course
Python for R Users
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Append values to a list
person_list.____(____)
# Print person_list
print(person_list)
# Print the last element of person_list
print(____)