[Tutor] set as iterable

Mark Lawrence breamoreboy at gmail.com
Mon Sep 28 12:28:03 EDT 2020


On 28/09/2020 14:29, Manprit Singh wrote:
> Dear sir ,
> 
> As you know there are lots of built in  functions in python standard
> library that accept an iterable as an argument. Some of the functions are:
> all , any, filter, map, max, min, sum, list, tuple, and so on, i will not
> include functions like enumerate since set is an unordered collection . Can
> I pass a set as an argument to these functions in place of an iterable ?
> 
> Regards
> Manprit Singh
> 

Why not try it from the interactive interpreter and see?

mark at mark-HP-15-Notebook-PC:~$ python3.8
Python 3.8.5 (default, Sep 12 2020, 00:59:31)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
 >>> a=set([1,9,5,6])
 >>> max(set([1,9,5,6]))
9

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list