Python

Replace all occurrences of a character in String in Python

In this article, we will discuss different ways to replace all occurrences of a character from a string in Python. Table Of Contents Using replace() function Using Regex Using translate() function Using replace() function In Python, the string class provides a function replace(to_be_replaced, replacement) to replace all occurrences of a sub-string in a string. We

Replace all occurrences of a character in String in Python Read More »

Remove duplicate spaces from string in Python

In this article, we will discuss different ways to delete duplicate spaces from a string in Python. Table Of Contents Remove duplicate spaces from string using split() and join() Remove duplicate spaces from string using Regex Suppose we have a string that contains some duplicate whitespaces, After removing duplicate whitespaces from it, the final string

Remove duplicate spaces from string in Python Read More »

Remove punctuation from String in Python

In this artilce, we will discuss different ways to remove all punctuation characters from a string in Python. Table Of Contents Remove punctuation from String using Regex Remove punctuation from String using replace() Remove punctuation from String using translate() Remove punctuation from String using filter() & join() The string package in python provides a variable

Remove punctuation from String in Python Read More »

Remove newline characters from string in Python

In this article, we will discuss different ways to delete all newline characters from a string in Python. Table of Contents Remove newline characters from string using Regex Remove newline characters from string using replace() function Remove newline characters from string using translate() Remove newline characters from string using filter() & join() Remove newline characters

Remove newline characters from string in Python Read More »

Remove Duplicate Characters from String in Python

This article will discuss different ways to remove duplicate characters from a string in Python. Table Of Contents Remove Duplicate Characters from String using set() and sorted() Remove Duplicate Characters from String using OrderedDict Remove Duplicate Characters from String using dict Remove Duplicate Characters from String using set Supose we have a string, We want

Remove Duplicate Characters from String in Python Read More »

Scroll to Top