Wednesday, November 4, 2020

String Formatting-3

 String Formatting-3

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
1. endswith()-to check whether string ends with a particular character(case sensitive)

-->print('numpy'.endswith('y'))

-->True

2. find()/index()- method finds the first occurrence of the specified value,returns -1 if not found,almost like index method.

-->print('Debug'.find('b'))

-->2

-->print('Debug'.find('s'))

-->-1

-->print('Debug'.index('s'))

-->ValueError



3. replace()- This method replaces a specified phrase with another specified phrase.

-->print('hi there'.replace('hi','hello'))

-->hello there



4. split()-splits a string into list,based on a seprator(default string).

-->print('harsh'.split())

-->['harsh']

-->print('h,a,r,s,h'.split(','))

-->['h','a','r','s','h']



5. join()-joins a iterable into string,using a seprator(default string).

-->print(','.join(['h','a','r','s','h']))

-->'h,a,r,s,h

Linear Search algorithm

Linear Search Algorithm Dear Readers, In this Blog today I would Share about Linear Search Algorithm a must know for everyone whether you wa...