Python How To Handle Invalid User Input

In this short article, we will show you a method to handle invalid user input. To tackle invalid inputs from the user, we can use the while block paired with the try-except blocks that Python provides for us. In this way, we can handle invalid inputs multiple times. Let’s see how. First, we use the … Read more

Python OSError: Explained!

In this article, let us learn about OSError. Let us learn what it means and why it is named that way with the help of some examples. To understand OSError, we must understand how the communication between Python and the operating system like Windows, Mac, Linux, etc, works. One of the main duties of the … Read more

Check If A Module Is Installed In Python

In this article, we’ll see a simple way to check if a module has been installed in Python or not You can check if a module is installed on your device or not by running the command shown below on your command line interface. (command prompt or Powershell if you are on Windows, and the … Read more

Python finally keyword explained with examples

The finally keyword is used alongside try-except blocks when handling exceptions. Although it is an optional block, it can be very handy in certain situations. For example, there will be scenarios where we’ll need to close a file or a network connection before the program is terminated. The finally keyword is utilized here because, regardless … Read more

Catch all errors except KeyboardInterrupt

In this article, we will learn how to catch all the errors in Python except KeyboardInterrupt. We will also be learning this alongside examples to make us understand better. Without further ado, let’s begin! First things first, let’s refresh our memories on the hierarchy of exceptions, refer to the following chart: What we’re trying to … Read more

5 Examples of Mutable Datatypes in Python

In this article let us look at 5 examples of mutable datatypes in Python. If you wish to develop your physique like Mr. Arnold, “understanding” how to perform exercises like squats, bench presses, etc., is not enough, you need to “consistently work your muscles” to build up your mass and strength! Learning Python is no … Read more

5 Examples of Immutable Datatypes in Python

In this article let us look at 5 examples of immutable datatypes in Python. If you wish to develop your physique like Mr. Arnold, “understanding” how to perform exercises like squats, bench presses, etc., is not enough, you need to “consistently work your muscles” to build up your mass and strength! Learning Python is no … Read more

Using Strings With Bytes in Python

Bytes is a data structure in Python that can be used when we wish to store a collection of bytes in an ordered manner in a contiguous area of memory. It is also an immutable data type. When working with data, you might find yourself in a situation where you need to convert bytes to … Read more