How to use the find function in python
This article mainly explains "how to use the find function in python". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the find function in python".
Specific steps for use:
1. First open the python editor and create a new python project.
2. Define 2 strings in the python project.
Str1 = "this is string example.wowning examples!"
Str2 = "exam"
3. Use the find function to detect whether the string str1 contains the substring str2 and return the index value.
Print str1.find (str2)
Return the result:
fifteen
Related sample code:
Mystring = "Meet Guru99 Tutorials Site.Best site for Python Tutorials!"
Print ("The position of Best site is at:", mystring.find ("Best site", 5,40))
Print ("The position of Guru99 is at:", mystring.find ("Guru99", 20))
# output results
The position of Best site is at: 27
The position of Guru99 is at:-1
Thank you for reading, the above is the content of "how to use the find function in python". After the study of this article, I believe you have a deeper understanding of how to use the find function in python, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!