Created
April 12, 2017 20:05
-
-
Save ebovio/6e9f777f4e569a84395721f3b6a85cd1 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
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