How to Check if a List is Empty in Python
Lists are one of the most common data types you’ll be using if you start coding with Python. One of the usual checks you may have to perform is to check if a list is empty. In this tutorial, we’ll…
Lists are one of the most common data types you’ll be using if you start coding with Python. One of the usual checks you may have to perform is to check if a list is empty. In this tutorial, we’ll…
Python provides a built-in module called datetime to manipulate dates and times. In a previous post, we say how to extract the year from a date using this module (the same logic can be used for days and months, by…
In a previous post, we explained how we can convert a string to a date object in Python. When you perform this action, it is often because you need to generate some kind of summary statistics, by year for instance.…
When you work with numerical list in Python, you may need to apply aggregation like finding the average. Most common operations are built-in in Python and no extra-code is needed. That being said, there is no function or method to…
Rounding a number is a common operation we often need to carry to ensure that the value in slightly changed to ensure its readability. In this tutorial, we’ll explain how you can round a number in Python and explain some…
If we look at the official documentation, we can realize that Python does not come with a native mean() or average() function, as it does with sum() or len(). Therefore, calculating the average of a list in Python is not…
Python comes with the datetime library to manipulate date and times. One of the most common manipulation we want to achieve is to convert a string representing a date to a real date object. By doing so, we’d be able…
In this tutorial, we’ll explore the different options you have at your disposal to move a file (or several files) from one location to another using simple Python code. We’ll explore two of the most used libraries for this operation:…
Getting the last element of a list is often counter-intuitive, but is sometimes needed for a logic we want to implement in Python. In this tutorial, we’ll explain the different methods you can use to extract the last element from…
In this simple tutorial, we will see how to split a string into a list of strings using the most common delimiter: the comma. Use the split() method to split a string by commas Python comes with a built-in method…