Skip to content

Commit 6e9a975

Browse files
authored
Clarify names in salsa example
The ingredients lists sound like actual mild and hot salsa already. By making more intuitive and informative names, we can model variable naming best practices and make it easier to follow the example. To do that, I edited both the code and the surrounding comments and text.
1 parent 06bb720 commit 6e9a975

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

_episodes/04-lists.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,31 +129,31 @@ does not.
129129
> the list value, it will change for both variables!
130130
>
131131
> ~~~
132-
> salsa = ['peppers', 'onions', 'cilantro', 'tomatoes']
133-
> my_salsa = salsa # <-- my_salsa and salsa point to the *same* list data in memory
134-
> salsa[0] = 'hot peppers'
135-
> print('Ingredients in my salsa:', my_salsa)
132+
> mlld_salsa = ['peppers', 'onions', 'cilantro', 'tomatoes']
133+
> hot_salsa = mild_salsa # <-- mild_salsa and hot_salsa point to the *same* list data in memory
134+
> hot_salsa[0] = 'hot peppers'
135+
> print('Ingredients in mild salsa:', mild_salsa)
136136
> ~~~
137137
> {: .language-python}
138138
>
139139
> ~~~
140-
> Ingredients in my salsa: ['hot peppers', 'onions', 'cilantro', 'tomatoes']
140+
> Ingredients in mild salsa: ['hot peppers', 'onions', 'cilantro', 'tomatoes']
141141
> ~~~
142142
> {: .output}
143143
>
144144
> If you want variables with mutable values to be independent, you
145145
> must make a copy of the value when you assign it.
146146
>
147147
> ~~~
148-
> salsa = ['peppers', 'onions', 'cilantro', 'tomatoes']
149-
> my_salsa = list(salsa) # <-- makes a *copy* of the list
150-
> salsa[0] = 'hot peppers'
151-
> print('Ingredients in my salsa:', my_salsa)
148+
> mild_salsa = ['peppers', 'onions', 'cilantro', 'tomatoes']
149+
> hot_salsa = list(mild_salsa) # <-- makes a *copy* of the list
150+
> hot_salsa[0] = 'hot peppers'
151+
> print('Ingredients in mild salsa:', mild_salsa)
152152
> ~~~
153153
> {: .language-python}
154154
>
155155
> ~~~
156-
> Ingredients in my salsa: ['peppers', 'onions', 'cilantro', 'tomatoes']
156+
> Ingredients in mild salsa: ['peppers', 'onions', 'cilantro', 'tomatoes']
157157
> ~~~
158158
> {: .output}
159159
>

0 commit comments

Comments
 (0)