Sarika Singh has Published 189 Articles

How to join two strings to convert to a single string in Python?

Sarika Singh

Sarika Singh

Updated on 09-Jun-2025 09:06:16

2K+ Views

In Python, we can join two strings into one single string using different ways, such as - Using the + Operator Using the join() Method Using Formatted Strings String Concatenation in Loops ... Read More

How to check if a character is upper-case in Python?

Sarika Singh

Sarika Singh

Updated on 09-Jun-2025 08:55:59

42K+ Views

In this article, we are going to find out how to check if a character is an uppercase letter in Python. We will explore four different approaches - Using the isupper() method Using regular expressions Using ASCII ... Read More

How to check if a string contains only lower case letters in Python?

Sarika Singh

Sarika Singh

Updated on 09-Jun-2025 08:17:16

4K+ Views

Checking for Lowercase Letters in PythonIn Python, a string is considered to have only lower-case letters if all its characters are alphabets and each one of them is in lower case (from 'a' to 'z'). We can verify this using the built-in islower() method, regular expressions, or by checking each ... Read More

How to check if a string contains only upper case letters in Python?

Sarika Singh

Sarika Singh

Updated on 09-Jun-2025 07:44:48

9K+ Views

Checking for Uppercase Letters in Python A string is considered to contain only upper-case letters if all its characters are alphabets and each one is in upper case (from 'A' to 'Z'). Python provides various ways to check this, such as using the isupper() method, regular expressions, or manually checking ... Read More

How to get the length of a string in Python?

Sarika Singh

Sarika Singh

Updated on 09-Jun-2025 07:25:27

3K+ Views

To find how many characters are present in a string (i.e. length of a string), Python provides the built-in function named len(). The length includes all characters in the string, including spaces, punctuation, and special characters. Using len() Function The len() function is the most direct way to find out how ... Read More

How to check if a string contains only whitespace letters in Python?

Sarika Singh

Sarika Singh

Updated on 09-Jun-2025 07:11:43

12K+ Views

A string is considered to contain only whitespace if it consists entirely of characters like space (' '), tab ('\t'), newline (''), carriage return ('\r'), etc. Python provides ways to check this directly using built-in functions or regular expressions. Using isspace() Method The isspace() method returns True if all characters ... Read More

How to catch an exception while using a Python \\\'with\\\' statement?

Sarika Singh

Sarika Singh

Updated on 08-Jun-2025 14:31:34

166 Views

In Python, the with statement is used when working with files or network connections. It makes sure that resources (files) are opened, used, and then closed properly, even if an error occurs during the process. If you want to catch any exceptions that happen inside a with block, you can ... Read More

Are Python Exceptions runtime errors?

Sarika Singh

Sarika Singh

Updated on 07-Jun-2025 22:13:54

964 Views

Are Python Exceptions Runtime Errors? Yes, Python exceptions are considered runtime errors. Most exceptions occur during runtime.Exceptions in Python are errors that occur when there is an abnormal scenario during the execution of a program, which terminates the execution abruptly, interrupting its normal flow. Examples of exceptions are ZeroDivisionError, IndexError, ... Read More

How to catch FloatingPointError Exception in Python?

Sarika Singh

Sarika Singh

Updated on 07-Jun-2025 20:25:51

2K+ Views

Catching FloatingPointError Exception in PythonFloatingPointError in Python is an exception that occurs when there is an error in floating-point calculations. By default, Python does not raise this error for basic operations like dividing by zero; instead, it returns inf or nan. To catch this error, you need to enable ... Read More

How to catch ImportError Exception in Python?

Sarika Singh

Sarika Singh

Updated on 07-Jun-2025 19:42:48

4K+ Views

The ImportError exception in Python is raised when the interpreter cannot find or load a module that is being imported using the import statement.  Catching the ImportError ExceptionLike any other exception, we can catch the ImportError exception using the try-except blocks. In this article, we discuss various scenarios where the ImportError exception occurs, ... Read More

Advertisements