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>pull/38526/head
parent
35ede1fc49
commit
e21439d7e8
|
@ -14,13 +14,13 @@ videoId: XzosGWLafrY
|
|||
|
||||
```yml
|
||||
question:
|
||||
text: Question
|
||||
text: How would you iterate over and print the keys and values of a dictionary named "user"?
|
||||
answers:
|
||||
- one
|
||||
- two
|
||||
- three
|
||||
- '<pre>for key in user.items():<br> print(key)</pre>'
|
||||
- '<pre>for key, value in user.all():<br> print(key, value)<br> print(value)'
|
||||
- '<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
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
|
|
Loading…
Reference in New Issue