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 Differentiate Iterator and Generator in PythonThis article gives the most basic differences between iterators and generators in Python, and illustrates these points with an example. How to Calculate Average and Grade in PythonThis article tells us how to calculate grade of students against 5 subject marks and get an average number for the subjects. How to Install Beautiful Soup in PythonThis article discusses 4 ways to install the beautiful soup library in Python. In the article, we have used PIP, APT, and WGET commands to install the beautiful soup library in Python. How to Send String Using Python SocketIn computer programming, socket programming connects two or more nodes on the same network to communicate with each other. One of these nodes plays the role of a server while the other serves as a client. How to Get the Reverse Complement of a DNA Strand Using PythonThis article discusses how we can create a reverse complement of a DNA strand using Python. It uses the in-built string methods and the Biopython module. How to Get Max Heap in PythonThis article illustrates how to get a max heap in Python by combining the heapq module with custom code. How to Profile a Python CodeThis tutorial demonstrates how to profile code to check its execution time in Python. How to Obfuscate Python CodeThis tutorial demonstrates to obfuscate Python's code to prevent it from being understood by humans. How to List All Files in Directory and Subdirectories in PythonThis tutorial demonstrates how to list all files in a directory and subdirectories in Python. How to Image Moments Using OpenCV in PythonThis tutorial discusses image moments using OpenCV in Python. How to Kill a Python ProcessThis article discusses three ways to kill a Python process. How to Imitate Ode45() Function in PythonThis article discusses the implementation of ode45() function in Python. Originally, the function is defined in MatLab. However, the article discusses the implementation of the ode45() function using the scipy module in Python. How to Create Text Menu With Infinite Loop in PythonThis article discusses the implementation of a text menu with an infinite loop in Python. It also discusses two ways to terminate the infinite loop. How to Solve The AttributeError: __Enter__ in PythonIn Python, the AttributeError is an error that is caused when you are using the object of a class with the with statement without defining the __enter__ function. How to Fix NameError: Variable Is Not Defined in PythonIn computer programming, at some point, you will deal with the scope of variables, which is the accessibility or boundary of a variable. Some variables can be accessed throughout the program while some can only be accessed within a specific block. How to Solve WARNING: An Illegal Reflective Access Operation Has OccurredAn illegal reflective access operation has occurred when you have used the Java Reflection API in a manner that is not permitted. The Java Reflection API is used to find out the names of fields, methods, constructors, and other classes and interfaces, as well as to invoke methods, constructors, and other methods. How to Fix ValueError: Too Many Values to UnpackThe ValueError too many values to unpack occurs when the number of variables does not meet the number of values either is an array or an input statement. How to Fix ValueError: Setting an Array Element With a Sequence in PythonIn Python, the ValueError: setting an array element with a sequence occurs when you try to assign an invalid data type to an array. This can also occur when you try to assign multiple values to a single location on the array. How to Fix ValueError: list.remove(x): X Not in List Error in PythonThis tutorial will teach you to fix ValueError: list.remove(x): x not in list in Python. How to Fix the SyntaxError: Can't Assign to Function Call in PythonAssigning functions to any variables helps us store the function's return value and use it accordingly. This improves the overall code and reduces the redundant lines of code. How to Fix IndexError: Invalid Index to Scalar VariableDiagnose and fix NumPy's IndexError: invalid index to scalar variable by checking whether an indexed value is a scalar or an array. How to Avoid the TypeError: Input Expected at Most 1 Argument, Got 3 in PythonIn this guide, we will understand how to solve the TypeError: input expected at most 1 argument, got 3. We will also understand the causes of this error. Almost every computer software uses the input statement to take data or commands from users and provides to the software to achieve a specific task or behavior. How to SIFT Using OpenCV in PythonThis tutorial discusses the SIFT technique using OpenCV in Python. How to Fix EnvironmentError: Mysql_config Not Found in PythonThis article will discuss how we can install and troubleshoot our MySQL Python installation and introduce a great alternative to the said package.