There are several modules available in Python to list files in a directory or folder. Some of the popular ones we can use are os, pathlib, glob, fnmatch, etc. This…
Python Convert Bytes to String
In this tutorial, we will take a look at how to convert bytes to string in Python. We can convert bytes to string using the below methods Using decode() method…
XOR in Python
XOR Operator in Python is also known as “exclusive or” that compares two binary numbers bitwise if two bits are identical XOR outputs as 0 and when two bits are different then…
Python Reverse a List: A Step-by-Step Tutorial
Reversing a list is a common requirement in any programming language. In this tutorial, we will learn the effective way to reverse a list in Python. There are 3 ways…
Python Delete File – Step-by-Step Guide
Python has several built-in modules that allow you to delete a file or remove directories. This tutorial is a step-by-step guide to remove a file or directory using 3 different…
ImportError: attempted relative import with no known parent package
Module imports sometimes can cause too much frustration if you are a Python beginner. This tutorial will learn how imports work and the solution for ImportError: attempted relative import with…
TypeError: string indices must be integers
In Python, the iterable objects are indexed using numbers. If you try to access the iterable objects using string, you will get typeerror: string indices must be integers. Python TypeError:…
TypeError: unhashable type: ‘dict’
In Python, all the dictionary keys must be hashable, so if you use any unhashable key type while adding a key into the dictionary, you will encounter TypeError: unhashable type: ‘dict’…
Number.isInteger() – JavaScript
In JavaScript, Number.isInteger() method checks whether the passed value is an integer or not. The method isInteger() returns true if the provided value is an integer or type number. Otherwise, it returns false. Syntax…
How to get file extension in Python?
In Python, we can extract the file extension using two approaches. Let’s take a look at each of these with examples. Python get file extension using os module splitext() function…
How to Check and Print Python Version?
In this tutorial, you will learn how to print the version of the current Python installation from the script. Print Python Version using sys Module The sys module comes as…
IndexError: too many indices for array
The indexerror: too many indices for an array means that you have a declared an array in a different dimension and trying to index it in another dimension. For example,…
How to get hostname in Python?
There are several ways to get a hostname in Python. The most popular and convenient way is to use the socket module, which provides the BSD socket interface. It’s available…
How to Generate a random string of a given length in Python?
In Python, Generating a random string is pretty straightforward. However, there are scenarios where we need to generate a random string that includes alphanumeric characters for a strong password. There…
TypeError: ‘module’ object is not callable
Python throws TypeError: ‘module’ object is not callable when you get confused between the class name and module name. There are several reasons why this might happen while coding. Let’s…
How to round to two decimals in Python?
This tutorial will learn how to round to two decimals in Python using round() and format() methods. Round to two decimals in Python When you deal with mathematical calculations in…
Python List length: How to Find Length of List in Python?
The list in Python is a collection datatype that is ordered and mutable. Lists allow you to store multiple elements in a single variable. A list can have duplicate elements…
Python ValueError: setting an array element with a sequence
In Python, if you are mainly working with numpy and creating a multi-dimensional array, you would have encountered valueerror: setting an array element with a sequence. What is valueerror: setting an…
TypeError: only integer scalar arrays can be converted to a scalar index
Python numpy throws typeerror: only integer scalar arrays can be converted to a scalar index when you try to convert the ordinary array into a scalar index. The other cause…
ValueError: invalid literal for int() with base 10
ValueError occurs when we pass an invalid argument type. The error is raised when we call int() function with string argument which Python cannot parse and throws ValueError: invalid literal for…
How to Get the Last Element of a List In Python
In this tutorial, let us look at the most efficient ways to find the last element in list in Python. What is a List in Python? The list is one…
SyntaxError: unexpected character after line continuation character
In Python, SyntaxError: unexpected character after line continuation character occurs when you misplace the escape character \ inside a string or characters that split into multiline. The backslash character “\” is used to indicate…
IndentationError: unexpected indent
Python language emphasizes indentation rather than using curly braces like other programming languages. So indentation matters in Python, as it gives the structure of your code blocks, and if you…
Python TypeError: ‘int’ object is not iterable
If you have read our previous article, the ‘NoneType’ object is not iterable. You already know why Python throws ‘typeerror‘, and it occurs basically during the iterations like for and while…
Python syntaxerror: eol while scanning string literal
Python is an interpreted language that means, unlike other languages(Java, C++, C#, etc.), Python doesn’t convert the entire code into low-level machine code at once; rather, each line of code…
Python typeerror: not all arguments converted during string formatting
In Python, typeerror: not all arguments converted during string formatting occurs mainly in 3 different cases. Applying incorrect format Specifier Incorrect formatting and substitution of values during string interpolation Mixing…
Python typeerror: ‘str’ object is not callable Solution
One of the most common errors in Python programming is typeerror: ‘str’ object is not callable, and sometimes it will be painful to debug or find why this issue appeared in…
Git error: src refspec master does not match any.
There are quite a few reasons Git throws an error: src refspec master does not match any. Let us look at each of these cases and the solution to it. When does…
object of type ‘closure’ is not subsettable
If you are working on R, a standard error message that you have faced is R is the object of type ‘closure’ is not subsettable. What does object of type ‘closure’…
How to check if a file exists in Python?
When you perform a file operation such as reading from a file or writing content to a file, we need to check if a file or directory exists before doing…
Python Check if String Contains Substring
In this tutorial, we will look at how to check if a string contains a substring in Python. A substring is a sequence of characters in a given string. Python…
Python IndexError: list index out of range
The IndexError: list index out of range occurs if you access an invalid index in your Python list, Generally it is raised when attempting to retrieve an index from a sequence (e.g.,…
‘python’ is not recognized as an internal or external command, operable program or batch file.
The ‘python’ is not recognized as an internal or external command, operable program or batch file. error is encountered in the command prompt of Windows after you install Python on the windows…
Python maximum recursion depth exceeded in comparison
Before jumping into an error, maximum recursion depth exceeded in comparison. Let’s first understand the basics of recursion and how recursion works in Python. What is Recursion? Recursion in computer language…
TypeError: ‘NoneType’ object is not iterable
If you are a python developer, then atleast for once, you would have faced this TypeEerror: ‘NoneType’ object is not iterable, and probably it occurs in iterations like for and while loops.…
Python typeerror: a bytes-like object is required, not ‘str’
What is TypeError in Python? The typeerror: a bytes-like object is required, not ‘str’ is generally raised when a certain operation is applied to an object of the incorrect type. …
Convert a list to string in Python
There are various scenarios where you would need to convert a list in python to a string. We will look into each of these scenarios in depth. Lists are one of…
Sort Dictionary by value in Python
Dictionary in Python is an unordered collection to store data values in key:value pairs. Since Dictionaries are unordered collections, it is not possible to sort the dictionary in Python. Hence some…
SyntaxError: unexpected EOF while parsing
The SyntaxError: unexpected EOF while parsing occurs if the Python interpreter reaches the end of your source code before executing all the code blocks. This happens if you forget to close the parenthesis…
fatal: refusing to merge unrelated histories [Solved]
The “fatal: refusing to merge unrelated histories” Git error occurs when two unrelated projects are merged, and two projects are unaware of each other existence and having mismatch commit histories. To provide a little…
Optimize Sitecore Media Library and Improve performance
Often i get a question asking How do we optimize the Sitecore media library Items and improve the performance of the website. Follow the simple checklist and ensure it is…
Sitecore Required license is missing: Runtime [Solved]
Sitecore is a paid CMS software that requires a valid license file. When writing the article, Sitecore doesn’t provide any trial or evaluation period to try out and purchase later.…
Disable Language Embedding in URLs and Sitecore Links
We know that Sitecore is a CMS and it supports multiple languages, hence the generated URL and Sitecore links will have a language appended to it for example(‘en’,’en-US’, etc.,). In this…
How to get Sitecore Media image URL in Code
In many scenarios, we would require Sitecore Image Item absolute URL to bind into the carousel, repeater or any other image component. We may need to read the Image Field…
How to create a JavaScript Dictionary and add key value pairs
Dictionary objects are very useful in any programming language. In this article let’s see how to create a JavaScript Dictionary and add key-value pairs. Many programming languages like C# and…
How to get the Current Page URL in Sitecore
There will be scenarios where you need to restrict/display certain data based on particular URL. In this article let’s take a look at how to get the current page URL…
How To Get A Sitecore Items Url?
In any Sitecore project if we have to link one page to another page we would require a URL of the page. This is one of the common task that…
How To Check if The Current Sitecore Page Is the Homepage?
As a Sitecore developer definitely we will come across this scenario where we want to go to the root item that is the home item. In certain situation, we may…
How to Schedule Tasks on Sitecore?
Sitecore has its own task scheduler and we can schedule any tasks or jobs on Sitecore. The approach to schedule tasks on Sitecore is pretty simple. Follow the steps mentioned below…
Creating Items from branch template in Sitecore Programmatically
Branch Templates are mainly used to build the reusable collection of items, or the hierarchy of items. Branch templates are very useful in creating the same structure at any path…