Category: Strings
Remove leading whitespace from String in Python
In this tutorial, we will learn about some methods using which we can remove leading whitespaces from a string in Python Programming language. Table Of Contents Introduction Method 1: Using lstrip() Method 2: Using sub() Summary Introduction Suppose we have a string with leading whitespaces i.e. Advertisements This is a sample text. Now we want …
Replace whitespaces with underscore in Python
In this Python tutorial, we will learn about the techniques through which we can replace all whitespaces with underscores in a string using the Python Programming language. Table Of Contents Method 1 : Using for loop Method 2 : Using str.replace() Method 3 : Using re.sub() Summary There are different ways to replace all whitespaces …
Check if a string starts with a substring in Python
In this Python tutorial, we wil learn about some methods using which we can check whether a string starts with a substring or not. Table Of Contents Introduction Check if a string starts with a substring using startswith() function: Check if a string starts with a substring using regex module Check if a string starts …
Check if a string starts with a substring in PythonRead More
Remove a List of Characters from a String in Python
In this article, we will discuss about some techniques, using which we can remove a list of characters from a string in Python Programming Language. Table Of Contents Introduction Method 1 : Using join() method Method 2 : Using re module Method 3 : Using translate() Summary Introduction Suppose we have a string and some …
Remove a List of Characters from a String in PythonRead More
Check if a string can be converted into float in Python
In this Python tutorial, we will discuss, how to check if a string can be converted into a float. Table Of Contents Using Regex to check if string can be converted into a float Using replace() and isdigit() to check if string can be converted into a float Using float() to check if string can …
Check if a string can be converted into float in PythonRead More
Python List – append() vs. extend()
In this Python tutorial, we will discuss the differences between append() and extend() methods of list. Table Of Contents append() method of List in Python extend() method of List in Python Difference between append() and extend() Similarities between append() and extend() Summary append() method of List in Python The append() method of class list adds …
Difference between Array and List in Python
In this tutorial, we will see the differences between an Array and a List in Python. Table Of Contents Arrays in Python NumPy Array array module in Python List in Python Differences between an Array and a List in Python Summary Arrays in Python Arrays in Python are homogeneous in nature, it means a NumPy …
Check if string ends with any string from List in Python
In this Python tutorial, we will discuss how to check if a string ends with one of the strings from a list. Table Of Contents Check if string ends with any string from List using endswith() method Check if string ends with any string from List using filter() and endswith() Check if the string ends …
Check if string ends with any string from List in PythonRead More
Check if string starts with any string from List in Python
In this Python tutorial, we will discuss how to check if a string starts with one of the strings from a list. Table Of Contents Check if string starts with any string from List using startswith() method Check if string starts with any string from List using filter() and startswith() Check if the string starts …
Check if string starts with any string from List in PythonRead More
How to split and parse a string in Python?
In this python tutorial, we will see how to split and parse a string in Python. Table Of Contents Split and parse a string using split() Example 1: Split a string by using space as the delimiter string Example 2: Split a string by using comma as the delimiter string Example 3: Split a string …