Skip to content

Commit 437fca4

Browse files
committed
added items dictionary loop
1 parent e709570 commit 437fca4

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

part-4.ipynb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,43 @@
392392
"metadata": {},
393393
"outputs": []
394394
},
395+
{
396+
"cell_type": "markdown",
397+
"metadata": {},
398+
"source": [
399+
"It's also possible to loop through the keys and values of a dictionary using the items method.\n",
400+
"Let's loop through the words dictionary and see how this works:"
401+
]
402+
},
403+
{
404+
"cell_type": "code",
405+
"collapsed": false,
406+
"input": [
407+
"for key, value in words.items():\n",
408+
" print(key, value)"
409+
],
410+
"language": "python",
411+
"metadata": {},
412+
"outputs": [
413+
{
414+
"output_type": "stream",
415+
"stream": "stdout",
416+
"text": [
417+
"el the\n",
418+
"gato cat\n",
419+
"perro dog\n",
420+
"en in\n",
421+
"la the\n",
422+
"burrito burrito\n",
423+
"casa house\n",
424+
"comio ate\n",
425+
"verde green\n",
426+
"esta is\n"
427+
]
428+
}
429+
],
430+
"prompt_number": 3
431+
},
395432
{
396433
"cell_type": "markdown",
397434
"metadata": {},

0 commit comments

Comments
 (0)