Skip to content

Commit 7de4db4

Browse files
authored
Resolves #1745
1 parent 328193f commit 7de4db4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

en/python_introduction/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,21 +391,23 @@ When should you use a dictionary or a list? Well, that's a good point to ponder.
391391
- Do you just need an ordered sequence of items? Go for a list.
392392
- Do you need to associate values with keys, so you can look them up efficiently (by key) later on? Use a dictionary.
393393

394-
Dictionaries, like lists, are *mutable*, meaning that they can be changed after they are created. You can add new key–value pairs to a dictionary after it is created, like this:
394+
395+
Like lists, using the `len()` function on the dictionaries returns the number of key–value pairs in the dictionary. Go ahead and type in this command:
395396

396397
{% filename %}command-line{% endfilename %}
397398
```python
398-
>>> participant['favorite_language'] = 'Python'
399+
>>> len(participant)
400+
3
399401
```
400402

401-
Like lists, using the `len()` function on the dictionaries returns the number of key–value pairs in the dictionary. Go ahead and type in this command:
403+
Dictionaries, like lists, are *mutable*, meaning that they can be changed after they are created. You can add new key–value pairs to a dictionary after it is created, like this:
402404

403405
{% filename %}command-line{% endfilename %}
404406
```python
405-
>>> len(participant)
406-
3
407+
>>> participant['favorite_language'] = 'Python'
407408
```
408409

410+
409411
I hope it makes sense up to now. :) Ready for some more fun with dictionaries? Read on for some amazing things.
410412

411413
You can use the `pop()` method to delete an item in the dictionary. Say, if you want to delete the entry corresponding to the key `'favorite_numbers'`, type in the following command:

0 commit comments

Comments
 (0)