Hint II
So, our eye is immediately drawn to this statement in the documentation:
To check if sub is a substring or not, use the in operator:
We could rewrite the code like this (test2.py):
for emoticon in emoticons:
if (emoticon in string_with_emoticons):
emoticon_start = string_with_emoticons.find(emoticon)
This nicely solves the issue with -1
, but the answer is still:
Oh, hai! Can I haz cheezeberger? :D
The fact is, the algorithm is broken: it doesn't check for multiple versions of the same emoticon. Can you find an alternative string function that would do the job better?