Skip to content

Instantly share code, notes, and snippets.

@AaronGoldsmith
Last active July 11, 2018 23:04
Show Gist options
  • Save AaronGoldsmith/307d486ff5caed21252e6cdd2d03871e to your computer and use it in GitHub Desktop.
Save AaronGoldsmith/307d486ff5caed21252e6cdd2d03871e to your computer and use it in GitHub Desktop.
example
def count_words(text):
num = 0;
for ch in text:
if(ch == " " or ch=="\n"):
num+=1
return num
str1 = "this is some text "
str2 = "this is some more text "
n1 = count_words(str1)
n2 = count_words(str2)
print(str1) # this is some text
print(n1) # 4
print(str2) # this is some more text
print(n2) # 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment