Skip to content

Commit 5d1d6b3

Browse files
committed
Use a for loop in dictionary example
1 parent d17d722 commit 5d1d6b3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

part-4.ipynb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,16 @@
286286
"cell_type": "markdown",
287287
"metadata": {},
288288
"source": [
289-
"Let's translate each word and save them in the list called translated_words. We'll generate this list by using a list comprehension."
289+
"Let's translate each word and save them in the list called translated_words. Let's start with an empty list and use a for loop to populate our list:"
290290
]
291291
},
292292
{
293293
"cell_type": "code",
294294
"collapsed": false,
295295
"input": [
296-
"translated_words = [print(words[spanish_word]) for spanish_word in sentence_words]"
296+
"translated_words = []\n",
297+
"for spanish_word in sentence_words:\n",
298+
" translated_words.append(words[spanish_word])"
297299
],
298300
"language": "python",
299301
"metadata": {},

0 commit comments

Comments
 (0)