Python String

Strings – you use it in every program, just like any other programming language. Learn about Strings in Python and how to manipulate them in the Pythonic way.

Python Template Strings

Python’s Template String Class provides a way for simple string substitution, wherein the template fields are substituted with suitable replacement strings provided by the user. Sometimes, it may be a preference to have an easier to replace string, rather than using other format strings for substitution. Template Strings are used exactly for this purpose, to […]

Python Template Strings Read More »

Python Remove Spaces from String

Python provides various ways to remove white-spaces from a String. This article will focus of some of the efficient techniques to remove spaces from a String. Either of the following techniques can be used to get rid of the spaces from a string: By using strip() method By using replace() method By using join() with

Python Remove Spaces from String Read More »

Python String Substring

Substring is a portion of the string that can be extracted and represented as a new string. In this tutorial, we will learn how to work with Substrings in Python. 1. Creating Python String Substring Substring can be created using either of the following methods: Slicing split() method Output: 2. Check for the presence of

Python String Substring Read More »

String Comparison in Python

The following are the ways to compare two string in Python: By using == (equal to) operator By using != (not equal to) operator By using sorted() method By using is operator By using Comparison operators 1. Comparing two strings using == (equal to) operator Output: Enter the first String: AA Enter the second String:

String Comparison in Python Read More »

Python Reverse String

Strings are basically sequence of characters. Python doesn’t support in-built string functions such as reverse() to reverse a string. The following are the ways to reverse a string in Python: By using a for loop By using a while loop By using a Slicing By using join() method By using Recursion By using List reverse()

Python Reverse String Read More »

Python String Functions

Python has built-in functions for almost every operation that is to be performed on a string. To make it simple, these are classified on the basis of the frequency of their use as well as their operations. They are as follows : Python String Functions Classification Basic Functions Advanced Functions Miscellaneous (These functions are not

Python String Functions Read More »

String Concatenation in Python

Concatenation is a method of joining strings together to form a new string altogether. The following are the methods to perform String Concatenation in Python: By using + operator By using join() method By using % operator By using format() function By Literal String Interpolation By using StringIO from IO Module By using += concatenate

String Concatenation in Python Read More »