Found 27104 Articles for Server Side Programming

How to replace all occurrences of a string with another string in Python?

Tarun Chandra
Updated on 19-Oct-2022 12:53:47

2K+ Views

A string is a group of characters that may be used to represent a single word or an entire phrase. In Python strings not require explicit declaration and may be defined with or without a specifier therefore, it is easy to use them. Python has various built in functions and methods for manipulating and accessing strings. Because everything in Python is an object, a string is an object of the String class, which has several methods. In this article, we are going to focus on replacing all occurrences of a string with another string in python. Using the replace() method ... Read More

How to get min alphabetical character from the string in Python?

Tarun Chandra
Updated on 19-Oct-2022 08:29:53

753 Views

A string is a collection of characters that can represent a single word or a whole sentence. Unlike Java there is no need to declare Python strings explicitly we can directly assign string value to a literal. For manipulating and accessing strings, Python include several built in functions and methods. A string is an object of the String class, which contains multiple methods because everything in Python is an object. In this article, we'll look at how to retrieve the minimum alphabetical character from a string in Python. The min() function The most common solution for this problem is to ... Read More

How to get max alphabetical character from the string in Python?

Tarun Chandra
Updated on 19-Oct-2022 08:21:58

951 Views

A string is a group of characters that may be used to represent a single word or an entire phrase. Strings are simple to use in Python since they do not require explicit declaration and may be defined with or without a specifier. Python provides a variety of built in functions and methods for manipulating and accessing strings in the class named string. In this article, we are going to find out how to get the max alphabetical character from the given string in python. The max() function The most used approach for this problem is the max() function from ... Read More

How to remove all leading whitespace in string in Python?

Tarun Chandra
Updated on 19-Oct-2022 08:10:17

16K+ Views

A string is a collection of characters that can represent a single word or a whole sentence. Strings are easy to use in Python since they don't need to be declared explicitly and may be defined with or without a specifier. For manipulating and accessing strings, Python provides built in functions and methods under the class “String”. Using these methods you can perform various operations on strings. In this article, we will be focusing on how to remove all leading whitespace from a string in python. Using the lstrip() function The basic approach is to use the lstrip() function from ... Read More

How to convert all uppercase letters in string to lowercase in Python?

Tarun Chandra
Updated on 19-Oct-2022 07:56:55

3K+ Views

A string is a group of characters that may be used to represent a single word or an entire phrase. Strings are simple to use in Python since they do not require explicit declaration and may be defined with or without a specifier. Python has various built in functions and methods for manipulating and accessing strings. Because everything in Python is an object, a string is an object of the String class, which has several methods. In this article, we are focusing on how to convert every uppercase letters into a string to lowercase letters. Using the lower() method One ... Read More

How can I fill out a Python string with spaces?

Tarun Chandra
Updated on 19-Oct-2022 07:50:47

10K+ Views

A string is a collection of characters that can represent a single word or a whole sentence. Unlike other technologies there is no need to be declared strings in Python explicitly we can define a string with or without the datatype specifier. A string in Python is an object of the String class, which contains multiple methods using which you can manipulate and access strings. In this article we are going to discuss fill out a Python string with spaces. Let’s see various solutions one by one. Using the ljust(), rjust() and center() methods To pad the string with desired ... Read More

How to get the length of a string in Python?

Tarun Chandra
Updated on 19-Oct-2022 07:42:30

2K+ Views

A string is a group of characters that may be used to represent a single word or an entire phrase. Strings are simple to use in Python since they do not require explicit declaration and may be defined with or without a specifier. Python has a variety of built in functions and methods for manipulating and accessing strings. Because everything in Python is an object, a string is an object of the String class, which has several methods. In this article we are going to discuss how to get the length of a string in Python. Using the len() function ... Read More

How to join two strings to convert to a single string in Python?

Tarun Chandra
Updated on 19-Oct-2022 07:39:32

2K+ Views

A string is a group of characters that can represent a single word or a complete sentence. Unlike in other technologies there is no need to declare strings in python explicitly using a datatype. Python provides several built-in functions using which we can manipulate strings. A string is an object of the String class, which has multiple methods because everything in Python is an object. In this article, we are focusing on how to combine 2 strings into a single string in python. Using the ‘+’ operator On way to join two strings is using the ‘+’ operator which is ... Read More

How to check if a character is upper-case in Python?

Tarun Chandra
Updated on 26-Aug-2023 03:47:56

36K+ Views

In this article, we are going to find out how to check if a character is an upper case in Python.. The first approach is by using the isupper() method. The Python standard library has a built-in method called isupper(). It supports the use of strings and other types of data. It shows whether a string of characters contains only capital letters. If at least one character is lowercase, it returns FALSE. Otherwise, if every letter in the string is capitalized, it returns TRUE. It doesn't need any parameters. Example In the example given below, we are taking 2 strings ... Read More

How to check if text is “empty” (spaces, tabs, newlines) in Python?

Tarun Chandra
Updated on 07-Dec-2022 06:57:59

3K+ Views

In this article, we are going to focus on how to check if the text is empty (spaces tabs newlines) in Python. The first method is to use the built-in string library's isspace() method. The isspace() method determines whether a string contains only spaces or contains any other characters. If the given string is only made up of spaces, this method returns true; otherwise, it returns false. Even if the string contains characters like t and n, the method returns true. Example In the program given below, we are taking 3 different strings and finding out if they contain only ... Read More

Advertisements