> floats = [1.5, 1.9, 2.0, 1.0]
> unique_integers = len(set(int(f) for f in floats))

And it can be written with set comprehension too.

>>> floats = [1.5, 1.9, 2.0, 1.0]
>>> len({int(x) for x in floats})
2

As my personal recommendation, map is OK only
when first argument is predefined.
In other words, I strongly prefer comprehension to map+lambda.

Regards,

INADA Naoki  <songofaca...@gmail.com>
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to