swcarpentry / python-novice-gapminder

Plotting and Programming in Python
http://swcarpentry.github.io/python-novice-gapminder/
Other
164 stars 431 forks source link

Improve solution to exercise in For Loop episode #519

Closed santisoler closed 3 years ago

santisoler commented 3 years ago

Improve the explanation of the solution for the "Identifying Variable Name Errors" exercise in the For Loops episode (12). Rearrange the expected errors to mimic the order in which they they would appear as we solve them. Add missing expected error for undefined variable a.

santisoler commented 3 years ago

I'm glad to be helpful. I was wondering if there's a way to put each one of the sentences I created as bullet items. I tried to do so, but the text was looking odd (fonts in purple and as they were inside the code block):

> {: .language-python}
> > ## Solution
> > * Python variable names are case sensitive: `number` and `Number` refer to
> > different variables.
> > * The variable `message` needs to be initialized as an empty list.
> > * We want to add the string `"a"` to `message` and not the undefined variable
> > `a`.

image

If there isn't an easy way to do that, I'm ok with how it looks right now.

alee commented 3 years ago

Thanks for the PR @santisoler ! In order to get it to render properly add a newline after your bulleted items, e.g.,

> {: .language-python}
> > ## Solution
> > - Python variable names are case sensitive: `number` and `Number` refer to different variables.
> > - The variable `message` needs to be initialized as an empty list.
> > - We want to add the string `"a"` to `message` and not the undefined variable `a`.
> > 
> > ~~~
...

I'm glad to be helpful. I was wondering if there's a way to put each one of the sentences I created as bullet items. I tried to do so, but the text was looking odd (fonts in purple and as they were inside the code block):

> {: .language-python}
> > ## Solution
> > * Python variable names are case sensitive: `number` and `Number` refer to
> > different variables.
> > * The variable `message` needs to be initialized as an empty list.
> > * We want to add the string `"a"` to `message` and not the undefined variable
> > `a`.

image

If there isn't an easy way to do that, I'm ok with how it looks right now.

santisoler commented 3 years ago

Thanks @alee for the tip! I just changed the sentences to a bullet list, which I think looks better.

I've also noticed that I messed with the type of the message variable: it's supposed to be a string and not a list! Already fixed that!

So feel free to merge if you agree.