Skip to content

Commit 9ec4796

Browse files
authored
Update 12-for-loops.md
Solution added for the exercise "Identifying Item Errors". Solution: index error.
1 parent ec1df2c commit 9ec4796

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

episodes/12-for-loops.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,5 +330,8 @@ print(total)
330330
> seasons = ['Spring', 'Summer', 'Fall', 'Winter']
331331
> print('My favorite season is ', seasons[4])
332332
> ~~~
333+
> > ## Solution
334+
> >
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.
333336
> {: .python}
334337
{: .challenge}

0 commit comments

Comments
 (0)