Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I wonder Why the output is 4?


SQL
word = "banana"
index = word.find("na", 3)
print(index)
Posted
Comments
PIEBALDconsult 28-Jul-14 19:59pm    
Because that's what you asked for?

1 solution

http://www.tutorialspoint.com/python/string_find.htm[^]

banana
012345
   >^


You asked for the first instance of "na" starting from offset 3 -- and that's at offset 4.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900