Python string or string in python is series of characters or element.In python idle or jupyter notebook a string is written as
a=’apple’
any element between single quotes or double quotes will create string in python.
a is a string.
a[0]
Output=’a’
as shown in image below
String In Python
Â
 Methods of String in Python:
String has many functions that can be used for working with strings.These methods make it easy to work with strings in Python, whether you’re formatting, searching, or manipulating text.
1 Str.Capitalize: To make the first character have upper case and the rest lower case.
2.Str.casefold: It Return a version of the string suitable for caseless comparisons.
3. Str.Center:It will return padded centered string.
4. Str.Count: To count number of times an object occurring in given string.
5.Str.encode:It Returns encodes version of string if not mentioned then in UTF 8 standard.
6.Str.endswith:It returns True or False if specified object matches with suffix in string.
7.Str.expandtabs:Will return copy of string in which all tab char are replaced with spaces.
8.Str.Find: It returns index of the substring which is to be find.
9.Str.Format: It returns the formatted version of string.
10. Str.Format_map: It takes values as dictionary and returns formatted version of string.
11. Str.index: It will returns the lowest index of string where substring is found in string.
12. Str.isalnum: It returns True if characters in given string are alphanumeric.
13. Str.isalpha:It returns True if characters in string are alphabetic.
14.Str.isdecimal:It returns True if characters in string are decimal numbers.
15.Str.isdigit: It returns True if characters in string are digit else returns False.
16.Str.isidentifier:It returns True if string is valid identifier else returns False.
17.Str.islower: It returns True if element in string are lowercase else returns False.
18. Str.isnumeric:It returns true if element in string are numeric else returns False.
19.Str.isprintable: It returns true if element in string are printable else returns False.
20. Str.isspace: It returns True if element in string are white spaces or space.
21. Str.istitle: It returns True if first character in string are upper case and rest are lower case else False.
22.Str.isupper: It returns True if all character in string are upper case else False.
23. Str.Join: It returns a string which is the concatenation of the two strings.
24. Str.ljust: It returns left justified string.
25.str.rjust:It returns right justified string.
26. Str.lower: It returns all letters in lower case.
27. Str.upper: It returns all elements in capital letters.
28. Str.lstrip:It removes all leading white spaces.
29.Str.rstrip:It removes all trailing white spaces.
30.Str.partition: It separate the string with separator and returns tuple with separator.
31.Str.maketrans:It returns translation table.
32.Str.replace: It will replace the old word with the new one in string.
33.Str.rpartition:It separate the string with separator and returns tuple with separator starting from end.
34.Str.split: It will split the string by given separator starting from beginning.
35.Str.rsplit: It will split the string by separator starting from end.
36. Str.startswith:It returns True when string starts with specified character else False.
37.Str.title: It turns first character of the word in capital letter.
38.Str.swapcase:It returns all letters in small case to capital and vice-versa.
39.Str.zfill:It pads a string with zero on left side, to return a string of specified width.
All above mentioned methods are used for string manipulation or working with string by clicking on link above you can learn more in details.
[…] a is string […]
[…] It will return the number of non-overlapping occurrences of substring or object in string. […]
[…] will return encode string in different given […]
[…] returns True if string endswith given suffix and False if suffix is not same as […]
[…] will return copy of string where all tab(t) characters are replaced with spaces. If tab size not given it will assume tab […]
[…] returns the lowest index in string where substring sub(which we want to find) is found and returns -1 if value is not present. Syntax: […]
[…] will return formatted version of given string. string can be formatted using ‘{}’.'{}’will be replaced by given element as […]
[…] String format_map in python takes dictionary as input and returns its key values in output. […]
[…] will return True if elements in String are alphanumeric i.e from A to Z and 0 to 9 else it will return false […]
[…] returns True if characters present in given string are alphabetic i.e A to Z else returns […]
[…] returns True if decimal numbers(0,1,2,3) present in string otherwise returns False. Decimals numbers are numbers with base 10 in numbers […]
[…] returns True if all the element in string are digits otherwise returns […]
[…] returns True if string is valid identifier as per language otherwise returns False. Identifiers start with A to Z ,a to z […]
[…] returns True if element in string are in lowercase else false if any one of the characters is capital as shown […]
[…] returns True if string contains printable element or empty other vise returns […]
[…] will return True if all the characters in string are white spaces such as /n,/v,/r,/f,/t and spaces other wise it returns […]
[…] will return True when first element of given string is upper case and rest are lower case otherwise […]
[…] returns True when all element in string are uppercase otherwise returns […]
[…] in string concatenates the two string with separator. As shown in image a and b are two string when a.join is […]
[…] String left just and right just will return left and right justified string as per width and fill character. […]
[…] will return all elements in string in lower case & upper will return all letters in upper case as shown […]
[…] will remove leading whitespaces in string and rstrip will remove trailing whitespaces if char are none otherwise char are removed as shown […]
[…] to number.It takes dictionary as input if only one argument , if there are two argument it must be string of equal length and in output each characters in x will be mapped to each character in y as […]
[…] separate the string with separator available in string otherwise it will return string and two empty […]
[…] is given count will replace only first occurrence of given word otherwise replace all elements in string with the new […]
[…] will return the lowest index in a string where substring sub is found and raise values error if substring not found in given […]
[…] & rsplit function both split the string by separator given in str.split does it from beginning and str.rsplit starting from end of string […]
[…] return True if string starts with specified prefix otherwise False. To determine whether string […]
[…] pads a string in python with zeros on left side and returns string with specified […]