String Find in Python
Level 246 keystrokes
This finds the position of a substring. The find() method returns the index of the first occurrence, or -1 if not found.
Python code
# Create a string to search in1text = "Hello World"# find() returns the starting index of the substring# "World" starts at index 6 in "Hello World"2print(text.find("World"))Output
6
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
"× 4(× 2)× 2.× 1=× 1