Comment

Comment by gspetr

No, there's literally a "find" str method.

str.find(sub[, start[, end]])

"Return the lowest index in the string where substring sub is found within the slice s[start:end]. Optional arguments start and end are interpreted as in slice notation. Return -1 if sub is not found."

Your instinct to resort to "in" is correc,t as it's generally slower than the "in" membership test, but the interviewer has even allowed the use of Google. Blanking out after that is really bad.

parent gspetr 5 months ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton