Python/basics.py

7 lines
188 B
Python
Raw Normal View History

2020-02-05 14:09:20 +00:00
def countstring(character, filepath):
myfile = open(filepath)
content = myfile.read()
myfile.close()
return(content.count(character))
2020-02-05 13:52:26 +00:00
2020-02-05 14:09:20 +00:00
print(countstring("a", "fruits.txt"))