
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10402 Articles for Python

2K+ Views
In Python, translating the string using a dictionary is used for text manipulation, encoding. It is typically achieved by using the str.translate() method along with the str.maketrans() to define the character mappings. The dictionary passed to the maketrans() contains key-value pairs where the keys are characters to replace and values are their corresponding replacements. Let's dive into the article to learn more about translating a string using the dictionary. Using Python str.translate() Method The Python str.translate() method is a sequel for the maketrans() method in the string module. This method uses the translation table generated by the ... Read More

3K+ Views
Converting the lowercase letters in a string to uppercase is a common task in Python. When working with the user input or formatting output, Python provides efficient ways to handle the letter casing. The most commonly used method is the built-in string method upper(). We can use loops and list comprehensions with this method, if we need to convert individual tokens of a string to upper case. Using python upper() Method The Python upper() method is used to convert all the lowercase characters present in a string into uppercase. However, if there are elements in the string that are already ... Read More

2K+ Views
A string is a group of characters that can represent a single word or a complete sentence. In Python there is no need to declare variables explicitly using the datatype specifier you can directly assign them to a literal. Therefore, compared to other technologies like Java it is easy to use Python strings. For manipulating and accessing strings, Python includes several built in functions and methods. You can find these functions in a class named String. In this article, we are going to focus on how to invert the case for all letters in a string in Python. Using the ... Read More

1K+ Views
In this article we are going to check whether the string starts with the substring or not, It is useful for checking whether the string starts with the substring, which is helpful in tasks like filtering data or validating input. In Python there are various ways to perform this check, such as startswith(), string slicing and regular expression. Let's dive into the article to learn more about them. Using python startswith() Method The Python startswith() method is used to check whether the string starts with a given substring or not. This method accepts a prefix string that you ... Read More

32K+ Views
In this article, we are going to find out how to split at newlines in Python. In general, split means to divide or to make a group of objects divide into smaller groups. The first approach to split at NEWLINES in python is by using the inbuilt method splitlines(). It takes a multi-line string as input and it returns a separated string that is divided at the new line. It doesn’t take any parameters. The splitlines() method is an inbuilt string method and it is used only for splitting at the new lines. Example 1 In the program given below, ... Read More

2K+ Views
While working with the strings in python, we will find the situations to break the string into parts. This is called splitting a string and is usually done based on a delimiter, this is nothing but a character or sequence of characters that separate the parts of the string. Python provides the several ways for achieving this, depending on whether the delimiter is simple string or a pattern. Let's dive into the article to learn more about splitting string by delimiter. Using python split() Method The python split() method is used to split the words in a string separated by ... Read More

4K+ Views
Any character or group of characters that depicts horizontal or vertical space is known as whitespace. A whitespace character usually takes up space on a page even though it does not correspond to any visible mark when it is rendered. Pressing the spacebar will allow you to enter a whitespace character. On many keyboards, the Tab key can also be used to enter horizontal whitespace, although the length of the space may vary. Any spaces or tabs that follow the final non-whitespace character on the line until the newline are considered trailing whitespace. Whitespace in Python Whitespace is a type ... Read More

612 Views
In python, Right-aligning the strings with space padding is a common requirement when formatting the text-based output such as reports, logs or tabular data. This can be done by using the built-in string methods. Let's dive into the article, to learn different ways to get a space-padded string with the original string right-justified in python. Using python rjust() Method The python rjust() method is used to right-align a string by padding it with a specified character on the left. Syntax Following is the syntax of python rjust() method − str.rjust(length, character) Example Let's look at the ... Read More

4K+ Views
In this article, we are going to find out how to search a string in backward direction in Python. The first method is to use the inbuilt python String class's rindex() method. The highest index of any substring in the given string is returned by the Python string rindex() method. By highest index, we mean that if a given substring appears twice or three times in a string, the rindex() method will return the index of the substring's rightmost or final occurrence. The main disadvantage of this function is that it throws an exception if the string contains no substrings. ... Read More

14K+ Views
In Python, working with strings is a common task in data processing and text analysis. The common operation is finding the last occurrence of a specific substring. It is useful in situations like extracting the domain names or locating the repeated elements in logs. Python provides several methods to accomplish this; the most commonly used are − Python rfind() Method Python rindex() Method Using python rfind() Method The Python rfind() method is used to find the last occurrence of the substring in the given string; if not found, ... Read More