Created
July 31, 2015 04:42
-
-
Save duonghau/0e99f494e8cc0f397028 to your computer and use it in GitHub Desktop.
countvoyels
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
#author Duong Tien Hau | |
#Enter a string and the program counts the number of vowels in the text. | |
#For added complexity have it report a sum of each vowel found. | |
def main(): | |
string=input("Enter a string:") | |
countvoyels(string) | |
def countvoyels(string): | |
voyels=dict(a=0,u=0,o=0,i=0,e=0) | |
for k in voyels: | |
voyels[k]=string.count(k) | |
print(k,voyels[k]) | |
total=0 | |
for k in voyels: | |
total+=voyels[k] | |
print("Total: {}".format(total)) | |
if __name__=="__main__": main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment