I'm studying Python and hung up on a simple problem. Let's say we have:string = helloWhen we invoke the find method on the string to find an empty string like this:string.find()Why does that equal to 0? I thought it would equal to -1 since an empty space could not be found.
Why does string.find() = 0?
programming languages;python
 is an empty string (I wouldn't call it an empty space - but I get your meaning).An empty string can be found everywhere that isn't a string. That is, a string that doesn't contain anything. This is probably true of many languages.This means there is an empty string before h, after h, before e, and so on.Think about it this way, we know that == is trueEmpty string equals empty string. A return of -1 would mean a failure; i.e. a non-match.Note that the  isn't just at the beginning as some of the answers here would suggest. I.e. The string isn't just  + hello.Have a look at this:string = hellostring.replace(, -)>>> -h-e-l-l-o-