Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Adding Items | Dictionary
Python Data Structures

Adding ItemsAdding Items

Let's build a dictionary named student.

Here's how you can add a key-value pair to a dictionary.

The student dictionary includes these pairs:

KeyValue
'first name''Ann'
'last name''Elliot'
'city''New York'
'country''USA'

Note

Single ' ' and double " " quotes in Python are interchangeable and equivalent.

Tarea

  1. Construct the following dictionary: 'name': 'Max', 'position': 'data scientist', 'level': 'junior';
  2. To the existing dictionary, append a new key named experience (as a string) with the value of 1.

¿Todo estuvo claro?

Sección 2. Capítulo 4
toggle bottom row
course content

Contenido del Curso

Python Data Structures

Adding ItemsAdding Items

Let's build a dictionary named student.

Here's how you can add a key-value pair to a dictionary.

The student dictionary includes these pairs:

KeyValue
'first name''Ann'
'last name''Elliot'
'city''New York'
'country''USA'

Note

Single ' ' and double " " quotes in Python are interchangeable and equivalent.

Tarea

  1. Construct the following dictionary: 'name': 'Max', 'position': 'data scientist', 'level': 'junior';
  2. To the existing dictionary, append a new key named experience (as a string) with the value of 1.

¿Todo estuvo claro?

Sección 2. Capítulo 4
toggle bottom row
some-alt