-2

I'm new to python, I study it by myself, and I just want to make sure I understand something about find() function...

If I want to find a specific string, it will find the first index of the first letter/number of the string or the the first time this strings?

for exaple, there's the next given string: "I$want$moeny$and$food"

If I type find('$') it will give me the first time '$' showed up in this string, which is 1.

However, if I want to find "$moeny", I will get the the number 6, means python serched where the full "$moeny" string is showed in the first time?

and If I type find('$mommy') it will give me an Error, and not index 1. Am I right? Did I understand it clearly? Thanks a lot :)

  • 5
    You can get answers to all your questions by empirical study: _try it yourself_ - why are you asking here? if you do not have a running python install, use some pyhton online resource like https://pyfiddle.io/ to test your code. SO does not _teach_ programming, it helps fixing mistakes. If you need learning ressources, use the info on the tag: https://stackoverflow.com/tags/python/info and look for learning resources or use the excellent https://docs.python.org/3/tutorial/ – Patrick Artner Nov 03 '18 at 20:09

1 Answers1

0

The best answer is to try it yourself and see what happens. A good practice is to enter the CMD or shell and type "python" and try various commands.

luke
  • 11
  • 2