Yaswanth Varma has Published 377 Articles

What is the most elegant way to check if the string is empty in Python?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2025 15:54:00

4K+ Views

The strings are the fundamental data types that are used to store text. When working with the string, Checking if the string is empty or not is a common task. An empty string is nothing but the string with zero characters. There are various to check if a sting ... Read More

How to remove empty strings from a list of strings in Python?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2025 15:51:52

9K+ Views

The Lists in Python are used to store collections of items such as numbers, strings. While working with the list of strings, it is common to find a empty strings in the list. An empty string is nothing but a string value with zero length. Officially they are present ... Read More

How to process escape sequences in a string in Python?

Yaswanth Varma

Yaswanth Varma

Updated on 21-Apr-2025 15:45:58

3K+ Views

The escape sequences are the special characters that are used to represent the whitespace characters, quotes, backslashes or non-printable characters within the string. These sequences start with the backslash followed by the character, For example result in newline. However, in some cases we will come across the ... Read More

How to convert hex string into int in Python?

Yaswanth Varma

Yaswanth Varma

Updated on 16-Apr-2025 17:40:11

48K+ Views

A Hexadecimal is the base-16 number system that uses the digits from the '0 to 9' and letters from 'A to F'. It is commonly used in the computers to represent the binary data in the readable format. In this article we are going to learn about converting hex string ... Read More

How to strip down all the punctuation from a string in Python?

Yaswanth Varma

Yaswanth Varma

Updated on 16-Apr-2025 17:37:48

2K+ Views

When working with the text data in Python, We will come across the situations where we find the unwanted punctuation marks (like ., :?!) to remove. Removing punctuation helps to normalize text, making it easier to analyze. Python provides the several ways to achieve this, Let's dive into the article ... Read More

How to get a variable name as a string in Python?

Yaswanth Varma

Yaswanth Varma

Updated on 16-Apr-2025 17:34:46

32K+ Views

In Python Variables are just the labels that are pointing to the values. They don't carry any built-in metadata about their names. That’s why there is no direct built-in method to get the variable name as a string. However, we can achieve this, by inspecting the environment such as ... Read More

How to get a function name as a string in Python?

Yaswanth Varma

Yaswanth Varma

Updated on 16-Apr-2025 17:28:57

17K+ Views

In Python, Functions are the first-class object, which means they can be passed around and manipulated like other data types (like integers, strings). This allows to inspect and retrieve the attribute of functions, including their names. In this article we are going to learn about getting the function names ... Read More

How can we change the id of an immutable string in Python?

Yaswanth Varma

Yaswanth Varma

Updated on 16-Apr-2025 17:26:18

1K+ Views

In Python,  strings are immutable, which means once the string is created, it cannot be changed. Because of this immutability, any operation that tries to modify the string results in creating a new string object with a different identity. Every object in Python has a unique identity, which can ... Read More

How do I execute a string containing Python code in Python?

Yaswanth Varma

Yaswanth Varma

Updated on 16-Apr-2025 17:06:56

19K+ Views

In Python, it is possible to execute the dynamically generated code or code stored as a string using the Python built-in functions like eval() and exec(). Both eval() and exec() functions should be used carefully, especially with untrusted input, as they execute any code, ... Read More

What does the \'b\' character do in front of a string literal in Python?

Yaswanth Varma

Yaswanth Varma

Updated on 15-Apr-2025 17:41:59

11K+ Views

A string is a collection of characters that can represent a single word or a complete phrase. Since you can directly assign strings in Python to a literal (unlike other technologies) it is easy to use them. The string literals are typically enclosed in quotes (' ' or " ") ... Read More

Advertisements