Python String

Python String Tutorials and Examples

Python String index()

Python String index() function returns the lowest index where the specified substring is found. If the substring is not found then ValueError is raised. Python String index() syntax This function syntax is: str.index(sub[, start[, end]])….

Python String expandtabs()

Python string expandtabs() function returns a new string with tab characters (\t) replaced with one or more whitespaces. Python String expandtabs() This function syntax is: str.expandtabs(tabsize=8) We can specify the tabsize parameter to specify the….

Python String casefold()

Python string casefold() function returns a casefolded copy of the string. This function is used to perform case-insensitive string comparison. Python String casefold() Let’s look at a simple example of casefold() function. s = ‘My….

Python String center()

Python string center() function returns a centered string of specified size. We can also specify the character to use for padding, the default is whitespace. Python String center() The function syntax is: str.center(width[, fillchar]) Let’s….

Python String capitalize()

Python String capitalize() function returns the capitalized version of the string. The first character of the returned string is converted to uppercase and rest of the characters are changed to lowercase. Python String capitalize() Let’s….

Python String endswith()

Python string endswith() function returns True if the string ends with the given suffix, otherwise it returns False. Python String endswith() This function syntax is: str.endswith(suffix[, start[, end]]) The suffix can be a string or….

Python String startswith()

Python string startswith() function returns True if the string starts with the given prefix, otherwise it returns False. Python String startswith() This function syntax is: str.startswith(prefix[, start[, end]]) The prefix can be a string or….

Python String Module

Python String module contains some constants, utility function, and classes for string manipulation. Python String Module It’s a built-in module and we have to import it before using any of its constants and classes. String….

Python String Substring

A substring is the part of a string. Python string provides various methods to create a substring, check if it contains a substring, index of substring etc. In this tutorial, we will look into various….

Python String count()

Python String count() function returns the number of occurrences of a substring in the given string. Python String count() The count() function syntax is: str.count(sub[, start[, end]]) sub is the substring to find in the….

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages