Here is my problem:
Return the number of times that the string
codeappears anywhere in the given string, except we'll accept any letter for the
I solved it by creating a list with all 26 possible
co_e combinations and then used two for loops to iterate through the list and search for matches in the given string.
Is there another way I could have created that list? or is there a way to ignore the third character in word and only search for matching characters 1, 2 and 4?
Here is my solution:
if len(inputstring)<4: return 0 wordlist=['coae','cobe','coce','code'...etc] count=0 for i in wordlist: for j in range(len(inputstring)): if inputstring[j:j+4] == i: count+=1 return count