import sys pattern = sys.argv[1] strToSearch = sys.argv[2] strToSearch = strToSearch.lower(); pattern = pattern.lower(); #create a function called match that takes two arguments, one the pattern, the other the string, returns true or false if the pattern is found or not found. use only functions to get the length of a string and one to return the nth character lenStr = len(strToSearch) lenPattern = len(pattern) strArr = [] for i in xrange(0,len(strToSearch)+1): strArr.append(strToSearch[i:i+lenPattern]) for i in strArr: if i == pattern: #print ("found") #print (i) print "found: ",i break """ else:#to see what and how many times it looped print (i) """ #is this valid? i mean I don't find the nth character i am splitting the string array into an array of strings...
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