Posts From Python String

Python Zfill

Python string zfill()

The Python string zfill() method is used to pad a string with zeros on the left until a specific width is reached. This is the most “Pythonic” way to add padding to a string, instead of manually iterating using for loops. Syntax of Python String zfill() Method The Python string zfill() function belongs to the […]

Python Lower

Python String lower() Method

Python String lower() method converts a string object into a lower case string. This is one of the builtin string functions in Python. Since strings are immutable in Python, this method only returns a copy of the original string. Syntax and Usage of Python String lower() Method Format: Here, str_copy is the lowercase string of […]

Python String ljust() and rjust() functions

Python String contains two built-in methods to provide the left and right justification. 1. Python String ljust() function Python String ljust() function accepts the character for padding it to the input string. Then, it substitutes the character and does padding to the right of the input string. Syntax: Parameters: length: The value of the length […]

Find String Length in Python

We can find string length in Python using the built-in len() function. Let’s look at how this function works, and also let’s try finding the length of various types of Python strings using len(). Using len() Let’s look at some simple examples to illustrate len(). This prints 20 because it is the number of characters […]

Python String find()

The Python string find() method is used to check if a string is a substring of another string. Often, when we want to check if a string contains another string, find() is very useful to solve this problem. Let us understand how we can use this, through some simple examples. Syntax of Python String Find() […]

Python – Convert String to List

In Python, if you ever need to deal with codebases that perform various calls to other APIs, there may be situations where you may receive a string in a list-like format, but still not explicitly a list. In situations like these, you may want to convert the string into a list. In this article, we […]