''' Problem #1 Substrings: Given 2 strings a and b, write a function which determines if a is a sub string of b. For eg. 'shop' is a sub-string of 'shopify'. You can assume that both the strings contain only alphabets and no special characters and that they are case insensitive. i.e 'DAD', 'Dad' and 'dad' will be considered equal. ''' a = "aasnkshopify" b = "shop" def is_substring(a,b): len_a = len(a) len_b = len(b) for i in range(0,len_a): str1 = a[i:i+len_b] if str1 == b: return True return False print is_substring(a,b)
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question