One of the common things that you can notice in many tasks is the fact that you need to sort elements in a list. In fact, this can also be part of an interview that you may go through while applying for a job. Maybe not only sorting elements, but sorting elements fulfilling certain conditions.
Continue readingTag: order
Two of the most common data structures in Python are lists and dictionaries. If you take a look back at your code, you may notice that you have a lot of lists and dictionaries used all over the place.
They may look quite similar, but they have a key difference. You can think of a list as a collection of items, and a dictionary as a collection of key-value pairs.
There can be cases when you may need to do a conversion of 2 lists into a single dictionary. This is something that you can easily do in Python with the help of zip() function.
Continue readingIt can be quite common that you have to work with a list:
- You may get a list of products from an API call
- You may get a list of people from a database
- You may get a list of items in an online store by reading from a CSV file
- You may get a list of numbers from a range
The list goes on.
Continue reading