ComenzarEmpieza gratis

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.

Este ejercicio forma parte del curso

Python for R Users

Ver curso

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

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

# Print person_list
print(person_list)

# Print the last element of person_list
print(____)
Editar y ejecutar código