Skip to content

Commit fc1cf37

Browse files
committed
fix formatting of 'What's in a Name?' callout
1 parent 0b97357 commit fc1cf37

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

_episodes/02-loop.md

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -152,39 +152,48 @@ The numbers in the diagram denote which loop cycle the character was printed in
152152
We can call the [loop variable]({{ page.root }}/reference/#loop-variable) anything we like,
153153
but there must be a colon at the end of the line starting the loop,
154154
and we must indent anything we want to run inside the loop. Unlike many other languages, there is no
155-
command to signify the end of the loop body (e.g. end for); what is indented after the for statement belongs to the loop.
155+
command to signify the end of the loop body (e.g. `end for`); what is indented after the `for` statement belongs to the loop.
156156

157157

158-
> ## What's in a name? {.callout}
158+
> ## What's in a name?
159+
>
159160
> In the example above, the loop variable was given the name `char` as a mnemonic; it is short for 'character'. 'Char' is not a keyword in Python that pulls the characters from words or strings. In fact when a similar loop is run over a list rather than a word, the output would be each member of that list printed in order, rather than the characters.
160-
>~~~ {.python}
161-
>list = ['oxygen','nitrogen','argon']
162-
>for char in list:
163-
> print(char)
164-
>~~~
165161
>
166-
>~~~ {.output}
167-
>oxygen
168-
>nitrogen
169-
>argon
170-
>~~~
162+
> ~~~
163+
> list = ['oxygen','nitrogen','argon']
164+
> for char in list:
165+
> print(char)
166+
> ~~~
167+
> {: .python}
168+
>
169+
> ~~~
170+
> oxygen
171+
> nitrogen
172+
> argon
173+
> ~~~
174+
> {: .output}
175+
>
171176
> We can choose any name we want for variables. We might just as easily have chosen the name `banana` for the loop variable, as long as we use the same name when we invoke the variable inside the loop:
172-
>~~~ {.python}
173-
>word = 'oxygen'
174-
>for banana in word:
175-
> print(banana)
176-
>~~~
177177
>
178-
>~~~ {.output}
179-
>o
180-
>x
181-
>y
182-
>g
183-
>e
184-
>n
185-
>~~~
178+
> ~~~
179+
> word = 'oxygen'
180+
> for banana in word:
181+
> print(banana)
182+
> ~~~
183+
> {: .python}
184+
>
185+
> ~~~
186+
> o
187+
> x
188+
> y
189+
> g
190+
> e
191+
> n
192+
> ~~~
193+
> {: .output}
194+
>
186195
> It is a good idea to choose variable names that are meaningful, otherwise it would be more difficult to understand what the loop is doing.
187-
196+
{: .callout}
188197
189198
Here's another loop that repeatedly updates a variable:
190199

0 commit comments

Comments
 (0)