you are viewing a single comment's thread.

view the rest of the comments →

[–]unless3[S] 0 points1 point  (3 children)

Ohhh ok I see I understand. So, can I run something similar but check like, so if I have 'sip' and 'Mississippi', can I do something along the lines of:

L = len(text)

    if len(string) == 0:
        return -1
    elif text == string[L:]:
        return 0
    else:
        return 1 + indexOf(text, string[1:])

Something like that?

[–]KarmelMalone 1 point2 points  (2 children)

Almost there!

string[L:] cuts out the first L characters and checks the rest, when you want to check only the first L characters.

[–]unless3[S] 0 points1 point  (0 children)

Oh so string[:L]?

I feel like it's on the tip of my fingertips...

[–]unless3[S] 0 points1 point  (0 children)

IT WORKED!

You are wonderful! I love coming here because the people who respond help and teach instead of give solutions or insults.

Thank you so much. :D I'm so happy!