Commit c466f98
committed
Fix to Chapter 3 solution: stats.py, us_population_stats_figure_2.png
chapter3/solutions/us_population_stats_figure_2.png is not correct
because the population growth list is unintentionally sorted by
`median()` in stats.py.
This commit replaces `numbers.sort()` in `median()` with
`sorted(numbers)`, which does not modify the list itself but returns a
new sorted list, and fixes us_population_stats_figure_2.png.
Before this commit:
>>> data = [3, 2, 1]
>>> median(data)
>>> print(data) #=> [1, 2, 3] (data is sorted.)
After this commit:
>>> data = [3, 2, 1]
>>> median(data)
>>> print(data) #=> [3, 2, 1] (data is not sorted.)1 parent e54a046 commit c466f98
2 files changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
Loading
0 commit comments