brewersfan1976

ch4-ex2.py

Aug 1st, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. # program that takes input from the user and only prints out words with lowercase vowels
  2. # digits or borth but not words with uppercase letters
  3.  
  4. import re
  5. from collections import Counter
  6.  
  7. userInput = raw_input("Please enter a sentence: ")
  8.  
  9. list = []
  10.  
  11. for w in userInput.split():
  12.     if re.search(r"[aeiou0123456789]", w):
  13.        if re.search(r"^[^A-Z]", w):
  14.           list.append(w)
  15.  
  16. list.sort()
  17.  
  18. print "We will now print the list in Alphabetical order"
  19. print
  20. print list
  21. print
  22. print "We will now print the list in descending order of frequency"
  23. print
  24.  
  25. words = Counter(list)
  26.  
  27. print words
Advertisement
Add Comment
Please, Sign In to add comment