In this tutorial, we will discuss how to remove the last word in a block of Python string, as shown in the example image below.
Continue readingCategory Archives: Python
Python Dictionary Not Subscriptable
Python throws the TypeError <object> is not subscriptable if you attempt to index using index operator ([ ]), an object which is not indexable. An indexable object contains the __getitem__() magic/dunder function, which allows the object to act as a container for some items.
Continue readingUnexpected Keyword Argument in Python
This is a Python TyperError that occurs when we try to call a function with a keyword argument that is not expected by the function. Let us reproduce the error and then see how to solve the error.
Continue readingRun Script From Another Directory in Python
There are two ways you may want to run a Python script located in another folder – as a regular script or import and run it as a module. This article focuses on how we can do this.
Continue readingRemove Unicode Characters in Python
What are Unicode Characters?
Character encoding, in simple terms, is a process of translating characters into integers or sequences of bits. Any character we can write has a corresponding representation in Unicode that is universally accepted across different languages.
Continue readingWrite New Line to a File in Python
A Quick Answer
In Python, one can write a new line into a file using either of the following methods:
Continue readingSet List Size in Python
Suppose you want to create a Python list of the predefined length? And suppose you want to create a list of lists with a certain size? Let’s find out what we can do in Python.
Continue readingCheck if Json Object Has Empty Value in Python
JSON is a data format available across platforms allowing the interchange of data in human-readable form. It stands for JavaScript Object Notation (JSON).
Python has a library called “json” that is used when working with JSON. JSON format works just like Python Dictionary except for the following value conversions:
Continue readingNameError name ‘requests’ is not defined in Python
NameError can occur for two reasons: we are trying to use the “requests” package before importing it, or the word “requests” is used as an identifier before being refined.
Continue readingCall Python Script From Bash With Arguments
Python scripts can be executed in different ways. The common way includes using JuPyter Notebook, IDE, and even text editors. This article focuses on running the code on the command line, specifically the cases we have to pass arguments.
Continue reading