Created
July 25, 2016 17:34
-
-
Save wohhie/53b84217f0973bab7ca51228a4d9d7cf to your computer and use it in GitHub Desktop.
❋ File Open ❋ Read the file
❋ Count Number of char with user choice
-------EXAMPLE------
This file contains hidden or 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
#count_char method. | |
#which count the total value | |
def count_char(text, char): | |
count = 0 | |
for c in text: | |
if( c == char): | |
count += 1 | |
return count; | |
#insert filename | |
filename = str(raw_input("Enter filename: ")) | |
#read data | |
with open(filename) as data: | |
text = data.read(); | |
#print data | |
#print(text); | |
#search for the value | |
count = str(count_char(text, "v")) | |
print("Counted value: " + count) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment