Python dict.fromkeys() Method

The method dict.fromkeys() is a very useful method for creating new dictionaries from a given iterable of keys. Definition: dict.fromkeys() is a method that inputs keys and maybe an optional value, and outputs a dictionary with the specified keys, that are mapped either to optionally specified values or to the default None value. dict.fromkeys() Syntax … Read more

Python __ifloordiv__() Magic Method

Syntax object.__ifloordiv__(self, other) The Python __ifloordiv__() magic method implements the in-place floor division operation x //= y that calculates the integer division operation x // y, and assigns the result to the first operands variable x. This operation is also called augmented arithmetic assignment. The method simply returns the new value to be assigned to … Read more

What is The Difference Between remove(), pop() and del in Lists in Python?

[toc] remove(), pop() and del can all be used to delete items from the list in Python. However, there are some underlying differences between these three functions with respect to the way they operate, error modes, and computational complexities. Let us try to understand the differences between the three and when to use them. remove() … Read more

How to Print Tab-Separated Values of a Python List?

[toc] Problem Statement: How to separate the items of a list in Python using tab as the delimiter? Example: The following example demonstrates an example of the given problem statement. The problem is self-explanatory. Hence, without wasting too much time, let’s dive into the various ways of solving this problem. Method 1: Using Escape Sequence … Read more

Find The Full Path of The Python Interpreter

[toc] Introduction Problem Statement: How to find the full path of the currently running Python interpreter? There are different ways to find the full path of Python interpreters. But first, let’s get the basics out of our way before we unearth the solution to our problem statement. So, what’s a Python Interpreter? This might be … Read more

Python Pandas melt()

Syntax pandas.melt(frame, id_vars=None, value_vars=None, var_name=None, value_name=’value’, col_level=None, ignore_index=True) Return Value The return value for the melt() function is an unpivoted DataFrame. Background Direct quote from the Pandas Documentation website: “This function massages a DataFrame into a format where one or more columns are identifier variables (id_vars). While all other columns are considered measured variables (value_vars), … Read more

Python __itruediv__() Magic Method

Syntax object.__itruediv__(self, other) The Python __itruediv__() magic method implements the in-place division operation x /= y that calculates the division operation x / y, and assigns the result to the first operands variable x. This operation is also called augmented arithmetic assignment. The method simply returns the new value to be assigned to the first … Read more

BeatifulSoup Find *

Preparation This article assumes you have the following libraries installed: Requests Beautifulsoup and a basic understanding of: HTML CSS Python Add the following code to the top of each code snippet. This snippet will allow the code in this article to run error-free. Beautifulsoup Find by ID If the HTML code contains one or more … Read more

How to Solve WebDriverException: Message: ‘geckodriver’ executable needs to be in PATH?

Did you get the “β€˜geckodriver’ executable needs to be in PATH?” error message when running your Python program? Are you searching for the answers in Q& A programming websites? But are you confused about the solutions provided on their websites? Are their solutions not working to rectify the issues? If your answer is YES. You … Read more