by Suf | Jan 27, 2022 | Programming, Python, Tips
This tutorial will go through how to use Python to count how often different items appear in a given list. You will learn how to do this using the count() list method, the naive implementation, the Counter() method from the collections library, values_count() from the...
by Suf | Jan 26, 2022 | Programming, Python, Tips
If you need to convert a list to a string in Python, there are several straightforward ways to do so. This tutorial will go through how to convert a list to a string with the different approaches with code examples. Table of contentsConvert a List to a String Using...
by Suf | Jan 26, 2022 | Programming, Python, Tips
If you need to remove empty strings from a list of strings in Python, there are several ways to do so. You can use the built-in methods remove(), join() and split() together, and filter(). You can also remove empty strings using list comprehension. This tutorial will...
by Suf | Jan 25, 2022 | Programming, Python, Tips
The length of a Python list is the same as the number of items in the list. You can find the length of a list using the built-in len() function. You can also use a for loop to iterate over the list and count the number of items. This tutorial will go through...
by Suf | Jan 24, 2022 | Programming, Python, Tips
The Cartesian product of two sets A and B denoted A x B is the set of all possible ordered pairs (a, b), where a is in A and b is in B. We can get the Cartesian product between two lists saved as a 2D list in Python. This tutorial will go through different methods to...