If foo="apple", then the following statements are equivalent:
foo.startswith("app")
foo[0:3] == "app"
In the sense that both will return "True".
Is there any reason to prefer one method over another? And by reason, I mean:
- Is one method significantly faster than the other?
- Is one method considered more or less 'Pythonic' than the other?