-
-
Save hector117/1fb06f57639605733fd897c29a0ce443 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
def find_bananas(nombre): | |
abierto = open(nombre,'r') | |
t = 0 | |
for line in abierto: | |
print("looking at: ",line) | |
line = line.lower() | |
index = line.find('banana') | |
while index > -1: | |
t = t + 1 | |
index = line.find("banana",index+1) | |
return t | |
#main program below | |
print("Problema 9 (Examen)") | |
nombre = input("Ingresa el nombre del archivo ") | |
print("Banana está escrita ",find_bananas(nombre)," veces en el archivo") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment