Functions set and sort | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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