a=“I love having apples juice ,and I like eat green apple”
a.find ('apple,30,len(a))
a.index(“apple”,30,len(a))in this program what is 30 and how we know this is 30 and what is len(a) why we use it?
In strings join,replace,and find functions in find function
the syntax for the same are-
string.find(“element”,start,end)
string.index(“element”,start,end)
element- the sub string which we want to find.
start-the index from where want to start our search from
end-the index up-to which we want to search.
If start and end indexes are not provided then by default it takes 0 and length-1 as starting and ending indexes.
We took 30 as our start randomly there is special reason for it .The only reason of taking 30 as starting index was to print the last occurrence of apple, since first occurrence of apple was at index 14 so we took an index value > 14.
len(a) is an inbuilt python function which will return the length of string in this case the length of string a is being returned.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.