Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change variable name from 'char' to 'letter' #569

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions _episodes/02-loop.md
Expand Up @@ -97,8 +97,8 @@ Here's a better approach:

~~~
word = 'lead'
for char in word:
print(char)
for letter in word:
print(letter)

~~~
{: .language-python}
Expand All @@ -116,8 +116,8 @@ hundred-letter string --- and more robust as well:

~~~
word = 'oxygen'
for char in word:
print(char)
for letter in word:
print(letter)
~~~
{: .language-python}

Expand Down Expand Up @@ -145,7 +145,7 @@ Using the oxygen example above, the loop might look like this:

![loop_image](../fig/loops_image.png)

where each character (`char`) in the variable `word` is looped through and printed one character
where each character (`letter`) in the variable `word` is looped through and printed one character
after another. The numbers in the diagram denote which loop cycle the character was printed in (1
being the first loop, and 6 being the final loop).

Expand All @@ -158,8 +158,7 @@ of the loop body (e.g. `end for`); what is indented after the `for` statement be
> ## What's in a name?
>
>
> In the example above, the loop variable was given the name `char` as a mnemonic;
> it is short for 'character'.
> In the example above, the loop variable was given the name `letter` as a mnemonic;
maxim-belkin marked this conversation as resolved.
Show resolved Hide resolved
> 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:
Expand Down