Created
April 16, 2017 19:28
-
-
Save ebovio/867b162abab97dbad0c318c40464917a to your computer and use it in GitHub Desktop.
This file contains 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
#Problem9 | |
import string | |
def find_bananas(file_name): | |
f = open(file_name,'r') | |
counter = 0 | |
for line in f: | |
line = line.lower() | |
index = line.find("banana") | |
while index > -1: | |
counter +=1 | |
index = line.find("banana",index+1) | |
return counter | |
#MainProgramBelow | |
print("The number of bananas in your file is", find_bananas("bananas.txt")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment