Skip to content

Instantly share code, notes, and snippets.

@duonghau
Created July 31, 2015 04:42
Show Gist options
  • Save duonghau/0e99f494e8cc0f397028 to your computer and use it in GitHub Desktop.
Save duonghau/0e99f494e8cc0f397028 to your computer and use it in GitHub Desktop.
countvoyels
#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