Lesson 25 of 34
lambda, sorted() மற்றும் keylambda, sorted() and key
9 min 30 XP
lambda என்பது ஒரே வரியில் எழுதும் சிறிய function. lambda x: x * 2 என்பது def double(x): return x * 2 போன்றதே.
A lambda is a tiny one-line function. lambda x: x * 2 is the same as def double(x): return x * 2.
Example: edit me and press Run
Press Run to see the result here.sorted(list, key=...) மூலம் எந்த அடிப்படையில் வரிசைப்படுத்த வேண்டும் என்று சொல்லலாம். reverse=True பெரியதிலிருந்து சிறியதாக.
sorted(list, key=...) lets you choose what to sort by. reverse=True sorts from largest to smallest.
Example: edit me and press Run
Press Run to see the result here.sorted() புதிய list தரும்; பழைய list மாறாது. list.sort() அதே list-ஐ மாற்றும்.
sorted() returns a new list and leaves the original alone. list.sort() changes the list itself.