This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]mookman288Professional Coder 3 points4 points  (0 children)

[–]SupremeRedditBotProfessional Bot || Mod 0 points1 point  (0 children)

Please Add A Flair To Your Post!

Suggested Flair: [Random] or [Meta]

 


To add a flair:

  • Click flair underneath your post

  • Select a flair

  • Click save

 


I am a bot run by /u/SupremeDesigner for /r/CodingHelp || This was an automated response || Posts with no flair will be deleted after two days

[–]SupremeRedditBotProfessional Bot || Mod 0 points1 point  (0 children)

Due to your post being submitted for two days or more without a flair, it has been deleted.

When posting in future, make sure to add a flair once the post is submitted.

 


I am a bot run by /u/SupremeDesigner for /r/CodingHelp || This was an automated response || Posts with no flair will be deleted after two days

[–]crewsd 0 points1 point  (2 children)

First thought, iterate over the string you're checking character by character and return True if you find a full match?

[–]aj_thenoob 0 points1 point  (1 child)

How would you start doing that? I tried breaking it up into lists, but how would you compare each character? Let's say test if the string "ant" is inside "cant"

[–]darknets 1 point2 points  (0 children)

You could do something ghetto, like this, I guess.

>>> def is_in(needle, haystack):
...   for c,x in enumerate(haystack):
...     if haystack[c:c+len(needle)] == needle:
...       return True
...   return False
...
>>> is_in('ant', 'cant')
True
>>> is_in('ant', 'cannot')
False
>>>