This article is about python programming skills from afternerd
Why we need lambdas (difference between traditional functions)
lambdas are only useful when you want to define a one-off function.
In other words, a function that will be used only once in your program. These functions are called anonymous functions.
How do I get the index of an element while I am iterating over a list?
The pythonic way is to use built-in
L = ['apples', 'bananas', 'oranges']
- enumerate tuple
- enumerate list of tuples
- enumerate a string
- Enumerate with a Different Starting Index
sort: object method
sorted: built-in function
- Sorting a list of numbers
- Sorting a list of strings
- Sorting a list of strings in a case insensitive manner
- Sorting a list of tuples
- Sorting a list of tuples by the second element
- Sorting a list of objects
append method is used to add an object to a list.
This object can be of any data type, a string, an integer, a boolean, or even another list.
extend is another very common list method.
Unlike append that can take an object of any type as an argument, extend can only take an iterable object as an argument.