CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Python for R Users

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Append values to a list
person_list.____(____)

# Print person_list
print(person_list)

# Print the last element of person_list
print(____)
Modifier et exécuter le code