diff --git a/basics.py b/basics.py index 8dbe163..9bcfb6a 100644 --- a/basics.py +++ b/basics.py @@ -1,5 +1,7 @@ -myfile = open("fruits.txt") -content = myfile.read(6) -myfile.close() +def countstring(character, filepath): + myfile = open(filepath) + content = myfile.read() + myfile.close() + return(content.count(character)) -print(content) \ No newline at end of file +print(countstring("a", "fruits.txt")) \ No newline at end of file