Practical solutions

Python How-To's How-To Guides

Solve the problem. Keep building. The collection of Python-related howtos

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Count the Occurrences of an Item in a One-Dimensional Array in PythonWe could use collections to count occurrences of an item in a Python array, or use unique, count_nonzero and bincount function in NumPy to get the number of occurrences. How to Join Two Sets in PythonThis article introduces how to join two sets in Python. How to Convert String to Float or Int in PythonThis tutorial introduces how to convert string to float or int in Python 2.7 and Python 3 How to Convert Bytes to String in Python 2 and Python 3This tutorial introduces how to convert bytes to string in Python 2.7 and Python 3, including decode and chr methods in Python 3.x. How to Create a List With a Specific Size in PythonThis tutorial shows how to create a list with a specific size in Python How to Get Dictionary Keys as a List in PythonThis tutorial introduces how to get dictionary keys as a list in Python How to Remove Multiple Elements From a List in PythonWe can use if...else control statements, list comprehensions, list slicing and for loops to remove multiple elements from a list in Python. How to Get Union of Lists in PythonUnion of Lists reflects that all the elements from the different lists will be put up inside a single list. How to Calculate Modular Multiplicative Inverse in PythonThis article explores how to calculate the modular multiplicative inverse in Python using the Naive Iterative Approach, Modular Exponentiation, the Extended Euclidean Algorithm, and Fermat's Little Theorem. How to Remove an Element From a Python DictionaryThis tutorial introduces how to remove an element from a Python dictionary How to Access Environment Variables in PythonThis tutorial article introduces how to read, change and append environment variables in Python. How to Deduplicate a List in PythonThis tutorial will introduce how to deduplicate a list in Python How to Initiate 2-D Array in PythonThis tutorial introduces how to initiate 2-D array How to Access the Index in 'Foreach' Loops in PythonThis tutorial article introduces how to access the index in foreach loop in Python. How to Check the Python Version in the ScriptsThis tutorial introduces how to check which Python version is interpreting the scripts. How to Merge Two Dictionaries in Python 2 and 3This tutorial introduces how to merge two dictionaries in Python 2 and 3. How to Check Whether a String Contains Substring in PythonThis tutorial introduces multiple ways to check whether a string contains a specific substring How to Convert String to Lowercase in Python 2 and 3It demonstrates how to convert a string or an unicode string to lowercase in Python 2 and 3 How to Find Files With a Certain Extension Only in PythonThis how-to article demonstrates how to find the files with a certain extension only in Python, and also introduces how to find such files in not only the directory but also its subdirectories. How to Convert String to Datetime in PythonIt demonstrates how to convert string to datetime in Python How to Convert Int to Binary in PythonThis tutorial will demonstrate how to convert integer to binary in Python How to Get the Average of a List in PythonThis tutorial will demonstrate how the average of a given list is obtained in Python using statistics.mean How to Find Maximum Value in Python DictionaryThe tutorial introduces how a key with maximum value in a dictionary is obtained in Python. How to Get the Day of the Week in PythonThe tutorial describes how to get the day of the week from the given date in Python.