Hafeezul Kareem

Hafeezul Kareem

258 Articles Published

Articles by Hafeezul Kareem

Page 4 of 26

Send SMS updates to mobile phone using python

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 2K+ Views

In this tutorial, we are going to learn how to send SMS messages in Python using the Twilio API service. Twilio provides a simple and reliable way to send SMS messages programmatically. Setting Up Twilio Account First, go to Twilio and create an account. You will get a free trial account with some credits to test SMS functionality. Complete the account setup and verify your phone number. Installation Install the twilio module using pip ? pip install twilio Getting Twilio Credentials From your Twilio Console Dashboard, you need to collect ? ...

Read More

self in Python class

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 2K+ Views

In this tutorial, we are going to learn about self in Python classes. The self parameter is a reference to the current instance of a class and is used to access variables and methods belonging to that instance. Note − self is not a keyword in Python. What is self? We use self in classes to represent the instance of an object. We can create multiple instances of a class and each instance will have different values. The self parameter helps us access those property values within the class instance. Basic Example Let's see how ...

Read More

Python Grouped Flattening of list

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 244 Views

In this tutorial, we will write a program that performs grouped flattening of a list containing sub-lists. This technique groups consecutive sublists together and flattens them into single lists, creating chunks of a specified size. Problem Statement Given a list of sublists and a number, we need to group the sublists in chunks of the given number and flatten each group into a single list. Input lists = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] number = 2 Expected Output [[1, 2, 3, 4], [5, 6, 7, 8], ...

Read More

Python How to copy a nested list

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 555 Views

In this tutorial, we are going to see different ways to copy a nested list in Python. A nested list is a list that contains other lists as elements. When copying nested lists, we need to create independent copies of both the outer list and inner lists to avoid unwanted modifications. Let's explore three effective methods to achieve this ? Using Nested Loops The most straightforward approach uses nested loops to manually copy each element ? # initializing a list nested_list = [[1, 2], [3, 4], [5, 6, 7]] # empty list copy_list = ...

Read More

Python Indexing a sublist

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 2K+ Views

In this tutorial, we will learn how to find the index of a sublist that contains a specific element. This is useful when working with nested lists where you need to locate which sublist contains your target element. Problem Statement Given a nested list, we need to find the index of the sublist that contains a specific element ? nested_list = [[1, 2, 3], [4, 5], [6, 7, 8, 9]] Expected output for elements 7, 5, and 3 ? Index of 7: 2 Index of 5: 1 Index of 3: 0 ...

Read More

Python Index specific cyclic iteration in list

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 1K+ Views

In this tutorial, we will learn how to cyclically iterate through a list starting from a specific index. Cyclic iteration means when we reach the end of the list, we continue from the beginning until all elements are visited. Algorithm Steps Initialize the list and starting index Find the length of the list using len() Iterate over the list using the length Find the current element index using (start_index + i) % length Print the element at that index Example Let's implement cyclic iteration starting from index 5 ? # initializing the ...

Read More

Python Grouping similar substrings in list

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 3K+ Views

In this tutorial, we are going to write a program that groups similar substrings from a list. We'll use Python's itertools.groupby() method to group strings that share a common prefix. Problem Understanding Given a list of strings with a common pattern (prefix-suffix), we want to group them by their prefix. Input strings = ['tutorials-python', 'tutorials-c', 'tutorials-java', 'tutorials-javascript', 'python-1', 'python-2', 'javascript-1'] Expected Output [['tutorials-python', 'tutorials-c', 'tutorials-java', 'tutorials-javascript'], ['python-1', 'python-2'], ['javascript-1']] Solution Using itertools.groupby() The itertools.groupby() method groups consecutive elements that have the same key. We'll use a lambda function ...

Read More

Python Group elements at same indices in a multi-list

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 758 Views

In this tutorial, we will write a program that groups elements at the same indices from multiple lists into a single list. This operation is also known as transposing a matrix. All input lists must have the same length. Example Input and Output Let's see what we want to achieve − # Input [[1, 2, 3], [4, 5, 6], [7, 8, 9]] # Output [[1, 4, 7], [2, 5, 8], [3, 6, 9]] Elements at index 0 from all lists: [1, 4, 7], elements at index 1: [2, 5, 8], and ...

Read More

Python Group Anagrams from given list

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 4K+ Views

In this tutorial, we are going to write a program that groups all anagrams in a list. First, let's see what are anagrams. Any two strings that have the same characters in a different order are known as anagrams. Before diving into the solution, let's see an example. Example Input and Output words = ['cat', 'dog', 'fired', 'god', 'pat', 'tap', 'fried', 'tac'] print("Input:", words) Input: ['cat', 'dog', 'fired', 'god', 'pat', 'tap', 'fried', 'tac'] Expected output: [['cat', 'tac'], ['dog', 'god'], ['fired', 'fried'], ['pat', 'tap']] Understanding the Approach ...

Read More

Python Getting sublist element till N

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 348 Views

In this tutorial, we will learn how to extract the first element from each sublist up to the Nth sublist in a nested list. For example, if we have a list with 5 sublists and want the first element from the first 3 sublists, Python provides several approaches to accomplish this. Let's explore different methods using the following example list: programming_languages = [['Python', 'Java'], ['C', 'Pascal'], ['Javascript', 'PHP'], ['C#', 'C++'], ['React', 'Angular']] print("Original list:", programming_languages) Original list: [['Python', 'Java'], ['C', 'Pascal'], ['Javascript', 'PHP'], ['C#', 'C++'], ['React', 'Angular']] Using For Loop The ...

Read More
Showing 31–40 of 258 articles
« Prev 1 2 3 4 5 6 26 Next »
Advertisements