string (1)
string (1)
programming we have string used in input and output the input function return a string form
keyboard and print function display a string on the console.string are considered as the most
popular data type present in python language string is a sequence of one or more character
here the character can be letter,digit,white space,or any other syntax an string can created by
enclosing one or more character in single,double and triple.
2.negative indexing : we can also print the element by using negative indexes. The negative
index start from last element and denoted -1 . negative index is very helpful in python string
when we have to print element from last and we dont know the length of the string. Negative
index are used when we want to access the character of the string from right to left
👍
>string method
1.capitalize : it converts the initial letter of the string to uppercase
2.casefold() : it converts the entire string to lowercase.
3.center() : it aligns the string at the center of the specified length.
4.count(): it returns the number of times a substring occurs in the given string.
5.encode() : it converts the string into the encoded version.
6.starwith() : it returns true if the given string starts with a specified substring.otherwise false.
7.endwith() : it returns true if the given string ends with a specified substring.otherwise false.
8.expandtabs() : the method sets the tab size to the specified number of whitespace.the default
tab size is 8 character space.
9.format() : it helps to format the string by making use of placeholders.