String Programs
String Basics
- Python – Create empty string Python Tutorial to create an empty string using single quotes, double quotes, or str() builtin function.
- Python – Create string using single quotes Python Tutorial to create a string by enclosing the value in single quotes.
- Python – Create string using double quotes Python Tutorial to create a string by enclosing the value in double quotes.
String Checks
- Python – Check if string ends with a specific suffix Python Tutorial to check if the given string ends with a specified suffix string.
- Python – Check if string starts with a specific prefix Python Tutorial to check if the given string starts with a specified prefix string.
String Find Operations
- Python – Count number of occurrences of a substring Python Tutorial to count the number of occurrences of a substring in the given string.
- Python – Find smallest string in a list based on length Python Tutorial to find the smallest string among the given strings, based on string length, using min() builtin function.
- Python – Find smallest of strings lexicographically in a list Python Tutorial to find the smallest string among the given strings lexicographically, i.e., based on arrangement in a dictionary order, using min() builtin function.
- Python – Get character at specific index from string Python Tutorial to get character from string at specified index.
- Python – Get first character from string Python Tutorial to get the first character from string using square brackets notation and 0 index.
- Python – Get last character from string Python Tutorial to get the last character from string using square brackets notation.
- Python – Length of string Python Tutorial to get the number of characters in a given string.
- Python – Substring Python Tutorial to find the substring in the given string, from a specific starting position to end position.
String Conversions
- Python – Convert string to a list of characters Python Tutorial to convert string to a list of characters.
String Operations
- Python – Escape single quote in a string Python Tutorial to escape a single quote when the string is created using single quotes.
- Python – Escape double quote in a string Python Tutorial to escape a double quote when the string is created using double quotes.
- Python – Iterate over characters of a string Python Tutorial to iterate over the characters of a string using For loop.
- Python – Print unique characters of a string Python Tutorial to get unique characters present in a string, and print them.
- Python – Replace substring in string Python Tutorial to to replace a specific substring in the given string with another new replacement string.
- Python – Sort list of strings Python Tutorial to sort the given list of strings in ascending or descending order.
- Python – Split string Python Tutorial to split the given string by a delimiter string.
- Python – Trim string Python Tutorial to trim a string at the edges. We can trim whitespaces or any specific set of characters from the edges of the given string.
Strings and Files
- Python – Write string to text file Python Tutorial to write given string to a text file.