Advertisement
brilliant_moves

CountVowels2.py

Sep 8th, 2014
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #!/usr/bin/python
  2. #CountVowels2.py
  3. #Python2.7
  4. #Count number of each vowel in a sentence
  5. #Chris Clarke
  6. #08.09.2014
  7.  
  8. the_string = raw_input("Enter some text: ")
  9. the_string = the_string.lower()
  10. vowels = {'a': 0, 'e': 0, 'i': 0, 'o': 0, 'u': 0};
  11.  
  12. for letter in the_string:
  13.     if letter == 'a':
  14.         vowels['a'] += 1
  15.     elif letter == 'e':
  16.         vowels['e'] += 1
  17.     elif letter == 'i':
  18.         vowels['i'] += 1
  19.     elif letter == 'o':
  20.         vowels['o'] += 1
  21.     elif letter == 'u':
  22.         vowels['u'] += 1
  23.  
  24. print "vowels['a']: ", vowels['a'];
  25. print "vowels['e']: ", vowels['e'];
  26. print "vowels['i']: ", vowels['i'];
  27. print "vowels['o']: ", vowels['o'];
  28. print "vowels['u']: ", vowels['u'];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement