0

Functions set and sort

What are they doing?

1st Sep 2018, 7:42 AM
Ilyich
1 Answer
+ 2
ā€œset()ā€ is a function, but ā€œsort()ā€ is a method. ā€œsorted()ā€ is a function. ā€œset()ā€ will return all distinct elements of a list, set etc., for example, if you set([1,2,2,3,3,3]) it will become {1,2,3} since 1, 2 and 3 are the only distinct numbers in this list. ā€œsort()ā€ can be applied to lists and ā€œsorted()ā€ to lists, sets and tuples... (ā€œsorted()ā€ will return a list and ā€œset()ā€ a set) Here’s how each of them works: https://code.sololearn.com/cgg0gpmuyHZ6/?ref=app
1st Sep 2018, 10:24 AM
Val
Val - avatar