Skip to content

Instantly share code, notes, and snippets.

@wrmedford
Created April 9, 2017 02:07
Show Gist options
  • Select an option

  • Save wrmedford/d35259774198ca6d125ef18c745f7ba5 to your computer and use it in GitHub Desktop.

Select an option

Save wrmedford/d35259774198ca6d125ef18c745f7ba5 to your computer and use it in GitHub Desktop.
def count_code(l):
x=l.split()
count = 0
c = False
o = False
r = 0
for i in range(len(x)):
if str(x[i]) == "c":
c = True
r = i
elif c == True:
if str(x[i]) == "o" & r -1 == i:
o = True
r = i
elif i - 2 == r & str(x[i]) == "e":
if c == True & "o" == True:
c = False
o = False
count +=1
elif i - 1 == r & c == True & o == True:
pass
else:
c = False
o = False
return count
count_code("code")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment