Tarun Chandra has Published 62 Articles

How to sort the letters in a string alphabetically in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 11:16:27

In this article, we are going to find out how to sort the letters in a string alphabetically in Python. The first approach is by using sorted() and join() methods. We send a string as input and we get alphabetically sorted string as output. We need to send the string ... Read More

How to convert a string to a list of words in python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 11:12:24

In this article, we are going to find out how to convert a string to a list of words in Python. The first approach is to use the built−in method split (). This function separates a text at the delimiter we specify. The delimiter parameter is sent to the split() ... Read More

How do I split a multi-line string into multiple lines?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 10:29:59

A string is a collection of characters that may be used to represent a single word or an entire phrase. Strings are useful in Python since they don't need to be declared explicitly and may be defined with or without a specifier. For dealing with and accessing strings, Python includes ... Read More

How do I remove a substring from the end of a string in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 10:26:24

In this article, we are going to find out how to remove a substring from the end of a string in Python. The first approach is by using slicing approach. In this method, we will check if the string is ending with the given substring or not, if it is ... Read More

How can I tell if a string repeats itself in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 10:22:47

In this article, we are going to find out how can we tell if a string repeats itself in Python. The first approach is by using slicing and find(). We want to see if the string we have is made up entirely of repeats of a substring of the string. ... Read More

How to do string concatenation without '+' operator in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 10:19:08

In this article, we are going to find out how to do string concatenation without plus operator in Python. The first technique is utilizing the string inbuilt library's join() method. To mix strings with a separator, use this approach. This method produces a string sequence as output. Python's join() method ... Read More

How to find the nth occurrence of substring in a string in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 10:15:37

In this article, we are going to find out how to find the nth occurrence of a substring in a string in Python. The first approach is by using the split() method. We have to define a function with arguments as string, substring, and the integer n. By dividing at ... Read More

How to convert a Python csv string to array?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 10:13:16

In this article, we are going to find out how to convert a CSV string into an array. The first approach is by using the split() method. This method takes a parameter, and delimiters the character at which the string should be split. Since the input is a csv, which ... Read More

How to remove a list of characters in string in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 10:10:35

In this article, we are going to find out how to remove a list of characters in string in Python. The first approach is by using the replace() method. This method takes 2 parameters, the character we would like to replace and the character with which we are replacing. This ... Read More

How to get integer values from a string in Python?

Tarun Chandra

Tarun Chandra

Updated on 07-Dec-2022 10:05:47

In this article, we are going to find out how to get integer values from a string in Python. The first approach is by using the filter() method. We will pass the string and the method isdigit() to the filter method. Python has a built-in function called Filter(). An iterable, ... Read More

1 2 3 4 5 6 7 Next
Advertisements