1- ## String Methods
1+ ## String : abc : Methods
22
3- - Python has a set of built in methods that you can use on strings
3+ - Python : snake : has a set of built in methods that you can use on strings
44- All string methods returns new values.they do not chnage the original string because string is immutable python object.
55
66Following are the most common used method for strings are
77
8- ## 1. capitalize():
8+ ## 1. capitalize() : a : :
99- The ** capitalize()** methodupper case the first letter in the given sequences.
1010
1111Example:
@@ -16,7 +16,7 @@ print(result)
1616# result:Hello
1717```
1818
19- ## 2. count():
19+ ## 2. count() : seven : :
2020- The ** count()** method returns the number of times a specified value appears in the string.
2121Example:
2222``` python
@@ -43,7 +43,7 @@ res=text1.count('i',6,len(text1))
4343print (result) # result:3
4444print (res) # result :1
4545```
46- ## 3. endswith()
46+ ## 3. endswith() : speech_balloon :
4747
4848- The ** endswith()** method returns True if the string ends with the specified value, otherwise False.
4949
@@ -68,7 +68,7 @@ print(mystring.index('k')) #result:error
6868
6969
7070
71- ## 5. find()
71+ ## 5. find() : alembic :
7272- To find out position of word or character from given string or paragraph use ** find()** method.
7373- The ** find()** method finds the first occurrence of the specified value.
7474- The ** find()** method returns -1 if the value is not found.
@@ -116,7 +116,7 @@ search=mystring.find("this")
116116print (search)
117117# result:-1
118118```
119- ### To find all occurrence of word
119+ ### To find all occurrence of word : beetle :
120120``` python
121121 for i,j in enumerate (mystring):
122122 if j== ' o' :
@@ -125,7 +125,7 @@ print(search)
125125
126126
127127
128- ## 6. Split()
128+ ## 6. Split() : frog :
129129- if you want to separate a string with white space or commas or some special character then split method is used
130130``` python
131131mystring= " india pakistan china america"
@@ -151,7 +151,7 @@ china
151151america
152152```
153153
154- ## 7. join()
154+ ## 7. join() : arrows_clockwise :
155155- The join() method takes all items in an iterable and joins them into one string.
156156- A string must be specified as the separator.
157157
@@ -168,7 +168,7 @@ strings=','.join(mylist)
168168print (strings) # result:india,pakistan,china,america
169169```
170170
171- ## 8. replace()
171+ ## 8. replace() : clipboard :
172172- ** replace()** method replaces a specified phrase with another specified phrase.
173173
174174Syntax:
@@ -194,7 +194,7 @@ print(newstring)
194194
195195## For Checking Data types there are following methods are present
196196
197- ### 1. isalnum()
197+ ### 1. isalnum() : 1st_place_medal :
198198- Returns True if all characters in the string are alphanumeric:
199199- True if all the characters are alphanumeric, meaning alphabet letter ** (a-z)** and numbers ** (0-9)** .
200200- False if any one character from non alphanumeric value (space)!#%&?
@@ -207,7 +207,7 @@ print(Res)
207207# result: true
208208```
209209
210- ### 2. isalpha()
210+ ### 2. isalpha() :A:
211211- ** isalpha()** method returns True if all the characters are alphabet letters (a-z).
212212- ** isalpha()** method return false if one of the characters is special character or number
213213
@@ -220,7 +220,7 @@ print(Res)
220220# result: false
221221```
222222
223- ### 3. isdecimal()
223+ ### 3. isdecimal() : one :
224224- The ** isdecimal()** method returns True if all the characters are decimals (0-9).
225225
226226example:
@@ -232,7 +232,7 @@ print(res)
232232# result:True
233233```
234234
235- ### 4. isdigit()
235+ ### 4. isdigit() : moneybag :
236236- ** isdigit()** method returns True if all the characters are digits, otherwise False.
237237
238238Example:
@@ -244,7 +244,7 @@ print(res)
244244# result : Tries
245245```
246246
247- ### Other some remaining methods
247+ ### Other some remaining methods
248248
249249** isidentifier()**
250250- Returns True if the string is an identifier
0 commit comments