Skip to content

Commit 72fc93a

Browse files
authored
Merge pull request #1747 from DjangoGirls/fix-dict-len-confusion
Fix `dict` `len` confusion
2 parents 328193f + 978fda2 commit 72fc93a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

en/python_introduction/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,19 +391,19 @@ 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+
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:
395395

396396
{% filename %}command-line{% endfilename %}
397397
```python
398-
>>> participant['favorite_language'] = 'Python'
398+
>>> len(participant)
399+
3
399400
```
400401

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:
402+
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:
402403

403404
{% filename %}command-line{% endfilename %}
404405
```python
405-
>>> len(participant)
406-
3
406+
>>> participant['favorite_language'] = 'Python'
407407
```
408408

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

0 commit comments

Comments
 (0)