Vikram Chiluka

Vikram Chiluka

216 Articles Published

Articles by Vikram Chiluka

Page 3 of 22

Python Program to Test if any set element exists in List

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 3K+ Views

In this article, we will learn how to check if any set element exists in a list using three different Python methods. Methods Used Using any() function Using bitwise & operator Using Counter(), filter() and lambda functions Example Problem We have an input set and input list. We need to check whether any element from the set exists in the list ? Input inputSet = {4, 8, 1, 3, 5, 7} inputList = [7, 15, 20] Expected Output Checking whether any set element present in the input ...

Read More

Python Program to Split a String by Custom Lengths

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 3K+ Views

In this article, we will learn how to split a string by custom lengths in Python. This technique is useful when you need to break a string into segments of specific sizes, such as parsing fixed-width data formats or creating chunks for processing. Methods Used The following are the various methods to accomplish this task − Using for loop and slicing Using List Comprehension with iter() and next() functions Problem Overview Let's understand the problem with an example. Assume we have an input string and custom lengths ...

Read More

Python Program to Sort A List Of Names By Last Name

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 2K+ Views

In this article, we will learn how to sort a list of names by last name using Python. This is a common task when working with name data that needs alphabetical ordering by surname. Methods Used Using lambda with sorted() function Using lambda with sort() method Example Overview Let's assume we have a list containing full names as strings. We need to sort these names alphabetically by their last names ? Input names = ['sachin tendulkar', 'suresh raina', 'hardik pandya'] Expected Output ['hardik pandya', 'suresh raina', 'sachin tendulkar'] ...

Read More

Python Program to Replace all words except the given word

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 442 Views

In this article, we will learn how to replace all words except the given word in a string in Python. This technique is useful for text processing where you want to mask certain words while preserving specific keywords. Methods Used The following are the various methods to accomplish this task: Using For Loop, split() & join() Functions Using List Comprehension Problem Statement Given an input string, we need to replace all words with a replacement character except for one specific word that should remain unchanged. Input ...

Read More

Python Program to Remove numbers with repeating digits

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 1K+ Views

In this article, we will learn how to remove numbers with repeating digits from a list in Python. Numbers like 3352 (3 appears twice) or 661 (6 appears twice) will be filtered out, keeping only numbers with unique digits. Problem Example Given an input list of numbers, we need to remove all numbers containing repeating digits ? Input inputList = [3352, 8135, 661, 7893, 99] Expected Output [8135, 7893] In the above example, 3352 has digit 3 repeated twice, 661 has digit 6 repeated, and 99 has digit 9 ...

Read More

Python program to remove K length words in String

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 667 Views

In this article, we will learn how to remove all words of a specific length (K) from a string using Python. This is useful for text processing tasks where you need to filter words based on their character count. Problem Statement Given an input string and a value K, we need to remove all words that have exactly K characters and return the modified string. Example inputString = "hello tutorialspoint python codes" k_length = 5 The output will be ? Resultant string after removing 5 length words: tutorialspoint python ...

Read More

Python Program to Remove all digits before given Number

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 390 Views

In this article, we will learn how to remove all digits before a given number from a string in Python. This task is useful when processing text data where you need to clean up numeric content selectively. Problem Overview Given an input string containing words and numbers, we want to remove all standalone digits that appear before a specific target number, while keeping the target number and everything after it intact. Example Consider this input ? inputString = 'hello 6 8 10 tutorialspoint 15 python codes' inputNumber = 10 The expected output ...

Read More

Python Program to move numbers to the end of the string

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 891 Views

In this article, we will learn different methods to move all numeric digits from their current positions to the end of a string while preserving the order of non-digit characters. Problem Overview Given a string containing letters, digits, and spaces, we need to extract all digits and append them to the end while keeping other characters in their original order. Input inputString = 'hello5691 tutorialspoint1342' Output Resultant string after adding digits at the end: hello tutorialspoint56911342 Here all the numbers 56911342 contained in the input string are moved to the end ...

Read More

Python Program to Join strings by multiple delimiters

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 577 Views

In this article, we will learn how to join strings by multiple delimiters in Python. This technique is useful when you need to create multiple variations of joined strings using different separators. Methods Used The following are the various methods to accomplish this task ? Using List Comprehension and "+" Operator Using List Comprehension and join() Function Example Overview Assume we have taken two input strings and a multiple delimiters list. We will now join both the input strings with the given input delimiters and return a resultant list ? Input ...

Read More

Python Program to Get word frequency in percentage

Vikram Chiluka
Vikram Chiluka
Updated on 27-Mar-2026 872 Views

In this article, we will learn how to calculate word frequency as percentages in Python. Given a list of strings, we'll find what percentage each word represents of the total word count. Formula Word Frequency (%) = (Occurrence of word / Total words) × 100 Method 1: Using Counter() from collections The Counter() function counts hashable objects and returns a dictionary-like object. The join() function connects sequence elements into a single string ? from collections import Counter # Input list of strings input_strings = ["hello tutorialspoint", "python codes", "tutorialspoint for python", ...

Read More
Showing 21–30 of 216 articles
« Prev 1 2 3 4 5 22 Next »
Advertisements