Name | .find() |
||||||
---|---|---|---|---|---|---|---|
Examples |
pet = 'sea snail' print(pet.find('a')) # Prints the index of the 'a' in 'pet': 2. print(pet.find('a', 3, 7)) # Prints the index of the second 'a' in # 'pet': 6. print(pet.find("snail")) # Prints 4. print(pet.find("rock")) # Prints -1. | ||||||
Description | Return the lowest index in the string where a substring is found. Optional arguments start and end specify a range to search in. If the substring is not found, returns -1. | ||||||
Syntax | a.find(sub) a.find(sub,start,end) | ||||||
Parameters |
| ||||||
Related |
string String Formatting .find() .strip() .join() .replace() |
Updated on Mon Sep 21 15:53:25 2020.
If you see any errors or have comments, please let us know.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License