Dictionary Iteration: Printing Key, Value Pairs (#38722)
* Dictionary Iteration: Printing Key, Value Pairs * Apply suggestions from code review Co-authored-by: Eric Leung <eric@erictleung.com> Co-authored-by: Beau Carnes <beaucarnes@gmail.com> Co-authored-by: Eric Leung <eric@erictleung.com>
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
35ede1fc49
commit
e21439d7e8
@ -14,13 +14,13 @@ videoId: XzosGWLafrY
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
question:
|
question:
|
||||||
text: Question
|
text: How would you iterate over and print the keys and values of a dictionary named "user"?
|
||||||
answers:
|
answers:
|
||||||
- one
|
- '<pre>for key in user.items():<br> print(key)</pre>'
|
||||||
- two
|
- '<pre>for key, value in user.all():<br> print(key, value)<br> print(value)'
|
||||||
- three
|
- '<pre>for key, value in user.items():<br> print(key, value)</pre>'
|
||||||
|
- '<pre>for key, value in user<br> print(key, value)</pre>'
|
||||||
solution: 3
|
solution: 3
|
||||||
```
|
```
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user