--Originally published at RAMGGV
Este programa es sobre una función que cuenta las veces que se escribió banana en el texto.



--Originally published at RAMGGV
Este programa es sobre una función que cuenta las veces que se escribió banana en el texto.
--Originally published at blog de Horacio
What to do:
Write a function called find_bananas which receives a single parameter called filename (a string) and returns a positive integer which is the number of times the word (string) “banana” (or “BANANA” ) is found in the file. The banana can be any case (‘BaNana’ or ‘BANANA’ or ‘banana’, etc) and they can be “stuck together” like “banAnaBANANA” (that counts as two). Create your own test file (plain text) to check your work.
progress:
Para contar palabras en un archivo de texto es necesario considerar varias cosas:
La palabra podría tener letras mayúsculas y minúsculas en ella, o podría estar junto a otra palabra sin ningún espacio, por lo que la función “dividir” no ayudará mucho.
Como puede ver, nuestro big_string tiene la palabra “bananas”, pero no todos los bananos tienen la misma estructura. Así que primero de todo. Convertiremos cada palabra en minúscula (línea 3).
Para dar más flexibilidad al programa, convertimos las letras de BaNana en minúsculas.
Después de eso, lo que haremos es buscar la palabra que verifica cada carácter, y mientras la cadena no está vacía, el programa lo comprobará y encontrará todos los plátanos.
--Originally published at Ken's Disciple 01
Hi guys in this WSQ 11 Fabrizzio Cortez helped me a lot with his video.
Pretty much this are the steps:
Code:
Code at GitHub
L.out
--Originally published at Adal´s Blog
--Originally published at Adal´s Blog
--Originally published at my programming blog
What I needed to do:
Write a function called find_bananas which receives a single parameter called filename (a string) and returns a positive integer which is the number of times the word (string) “banana” (or “BANANA” ) is found in the file. The banana can be any case (‘BaNana’ or ‘BANANA’ or ‘banana’, etc) and they can be “stuck together” like “banAnaBANANA” (that counts as two). Create your own test file (plain text) to check your work.
Thanks to this tutorial and this post.
So what I did was:
My code in Github: https://gist.github.com/mariasantoyodl/31c998d729a8e608a0abfe31e59cf8e5
--Originally published at Programming course
So this assignment was longer than I expected but it was fun
here is what we had to do:
Write a function called find_bananas which receives a single parameter called filename (a string) and returns a positive integer which is the number of times the word (string) “banana” (or “BANANA” ) is found in the file. The banana can be any case (‘BaNana’ or ‘BANANA’ or ‘banana’, etc) and they can be “stuck together” like “banAnaBANANA” (that counts as two). Create your own test file (plain text) to check your work.
And my code
--Originally published at Let's CODE