On Wed, May 10, 2017 at 10:11 PM, Andre Müller <gbs.dead...@gmail.com> wrote:
> 1.) a short example for Python 3, but not exactly what they want.
>
> def square(numbers):
>     yield from sorted(n**2 for n in numbers)
>
> numberlist = [99, 4, 3, 5, 6, 7, 0]
> result = list(square(numberlist))

If you're going to use sorted(), why not simply return the list
directly? This unnecessarily iterates through the list and builds a
new one.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to