Python String rjust()

Returns a right-justified string filling up the left-hand side with fill characters. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.rjust(width[, fillchar]) Returns a right-justified string filling up the left-hand side with fill characters. width – the number of … Read more

Python String rindex()

Return the highest index in the string where a substring is found. Returns ValueError if not found. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.rindex(sub[, start[, end]]) Return the highest index in the string where a substring is … Read more

Python String rfind()

Return the highest index in the string where a substring is found. Returns -1 if not found. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.rfind(sub[, start[, end]]) Return the highest index in the string where a substring is … Read more

Python String replace()

Returns a string with replaced values. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.replace(old, new[, count]) Returns a string with replaced values. Return a copy of the string with all occurrences of substring old replaced by new. If … Read more

Python String removesuffix()

Return string[:-len(suffix)] if the string starts with suffix, and string[:] otherwise. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.removesuffix(suffix, /) The method creates a new string from the original string by removing the suffix passed as an argument. … Read more

Python String removeprefix()

Return string[len(prefix):] if the string starts with prefix, and string[:] otherwise. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.removeprefix(prefix) The method creates a new string from the original string by removing the prefix passed as an argument. Formally, … Read more

Python String partition()

Searches for a separator substring and returns a tuple with three strings: (1) everything before the separator, (2) the separator itself, and (3) everything after it. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.partition(sep) Searches for a separator … Read more

Python String maketrans()

Returns a translation table. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation static str.maketrans(x[, y[, z]]) Returns a translation table—think of it as a dictionary—that you can pass into the str.translate() method to translate all characters in the string … Read more

Python String lstrip()

Trims whitespaces on the left and returns a new string. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.lstrip([chars]) Trims whitespaces on the left and returns a new string. chars – optional. The argument defines the set of characters … Read more

Python String lower()

Returns a lowercase string version. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.lower() Returns a lowercase string version. Here are a few examples: You can find the full algorithm for lowercasing a string in the section 3.13 of … Read more

Python String ljust()

Returns a left-justified string filling up the right-hand side with fill characters. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.ljust(width[, fillchar]) Returns a left-justified string filling up the right-hand side with fill characters. width – the number of … Read more

Python String join()

Concatenates the elements in an iterable. Minimal Example As you read over the explanations below, feel free to watch our video guide about this particular string method: Syntax and Explanation str.join(iterable) Concatenates the elements in an iterable. The result is a string whereas each elements in the iterable are “glued together” using the string on … Read more