NameError: name ‘reduce’ is not defined in Python
It was moved to functools.
It was moved to functools.
On Python 3.4+ you can use statistics.mean() On older versions of Python you can do On Python 2 you need to convert len to a float to get float division There is no need to use reduce. It is much slower and was removed in Python 3.
You can read about the changes in What’s New In Python 3.0. You should read it thoroughly when you move from 2.x to 3.x since a lot has been changed. The whole answer here are quotes from the documentation. Views And Iterators Instead Of Lists Some well-known APIs no longer return lists: […] map() and filter() return iterators. If … Read more