Skip to content

Commit 214d3c4

Browse files
committed
Add formatting to Identifying Item Errors solution
1 parent 9ec4796 commit 214d3c4

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

episodes/12-for-loops.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,17 @@ print(total)
330330
> seasons = ['Spring', 'Summer', 'Fall', 'Winter']
331331
> print('My favorite season is ', seasons[4])
332332
> ~~~
333+
> {: .python}
334+
>
333335
> > ## Solution
334336
> >
335-
> > It is an index error. The problem is that 4 points to an item that doesn't exist in the list. Remember the first item of a list in Python is 0. Subtitute seasons[4] for seasons[0], seasons[1], seasons[2] or seasons[3] to have the different items of the list printed.
336-
> {: .python}
337+
> > It is an index error:
338+
> > ~~~
339+
> > IndexError: list index out of range
340+
> > ~~~
341+
> > {: .error}
342+
> >
343+
> > The problem is that `4` points to an item that doesn't exist in the list. Remember the first item of a list in Python is `0`.
344+
> > Replace `seasons[4]` with `seasons[0]`, `seasons[1]`, `seasons[2]` or `seasons[3]` to have the different items of the list printed.
345+
> {: .solution}
337346
{: .challenge}

0 commit comments

Comments
 (0)