We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: Characters

Python : How to iterate over the characters in string ?

In this article we will discuss different ways to iterate or loop over all the characters of string in forward, backward direction and also by skipping over certain characters. Iterate over string using for loop Iterating over the string is simple using for loop and in operator i.e. Advertisements sampleStr = “Hello!!” print(“**** Iterate over …

Python : How to iterate over the characters in string ?Read More

Python : How to replace single or multiple characters in a string ?

In this article we will discuss how to replace single or multiple characters in a string in Python. Python provides a str.replace() function i.e. Advertisements str.replace(old, new , count) It returns a new string object that is a copy of existing string with replaced content. Also, If count is not provides then it will return …

Python : How to replace single or multiple characters in a string ?Read More

Find frequency of each character in string and their indices | Finding duplicate characters in a string

In this article we will discuss different ways to fetch the frequency or occurrence count of each character in the string and their index positions in the string using collections.Counter() and regex. Get Frequency of each character in string using collections.Counter() collections.counter(iterable-or-mapping) Counter is a dict subclass and collections.Counter() accepts an iterable entity as argument …

Find frequency of each character in string and their indices | Finding duplicate characters in a stringRead More

Count occurrences of a single or multiple characters in string and find their index positions

In this article we will discuss different ways to count occurrences of a single character or some selected characters in a string and find their index positions in the string. Count Occurrences of a single character in a String using string.count() In Python the String class contains a method to count to the occurrences of …

Count occurrences of a single or multiple characters in string and find their index positionsRead More

Python: Remove characters from string by regex & 4 other ways

In this article we will discuss different ways to delete single or multiple characters from string in python either by using regex() or translate() or replace() or join() or filter(). Remove characters from string using regex Python’s regex module provides a function sub() i.e. Advertisements re.sub(pattern, repl, string, count=0, flags=0) It returns a new string. …

Python: Remove characters from string by regex & 4 other waysRead More

Cart

Your Cart is Empty

Back To Shop