Last active
July 11, 2018 23:04
-
-
Save AaronGoldsmith/307d486ff5caed21252e6cdd2d03871e to your computer and use it in GitHub Desktop.
example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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