Latest Posts From Safa Mulani

Introduction to Python Modules

Modules are the pre-defined files that contain the python codes which depict the basic functionalities of class, methods, variables, etc. It consists of different functions, classes in a group of files inside a directory. Modules can also be termed as Libraries. These are basically the pre-defined methods that can be used to make the code […]

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: […]

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() […]

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 operator 1. […]

How to Check if a String contains a Substring in Python?

A substring is a sequence of characters within a String. The following are the methods in Python to check if a string contains another string i.e. substring. By using find() method By using in operator By using count() method By using str.index() method By using operator.contains() method Method 1: By using find() method The method […]

Python Set – Things You MUST Know

Python set is an un-ordered and un-indexed collection of elements. Every element is unique. The set contains elements that are un-ordered. No duplicates are allowed. The set itself is mutable i.e. one can add/remove items(elements) from it. Unlike arrays, wherein the elements are stored in order, the order of elements in a set is not […]