Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. from functools import reduce
  2. import re
  3.  
  4. initial_string = input()
  5.  
  6. separators = (',', ';', ':', '.', '!', '(', ')', '"', '\'', '\\', '/', '[', ']')
  7.  
  8. initial_string = reduce(lambda s, sep: s.replace(sep, ' '), separators, initial_string)
  9.  
  10. words_list = initial_string.split()
  11.  
  12.  
  13. def run(word):
  14. chars = re.compile('[@_!#$%^&*()<>?/|}{~:]')
  15. if chars.search(word) == None:
  16. return False
  17. else:
  18. return True
  19.  
  20. lower_list = []
  21. upper_list = []
  22. mixed_list = []
  23.  
  24.  
  25. for word in words_list:
  26. if word.islower():
  27. lower_list.append(word)
  28. elif word.isupper() and not run(word):
  29. upper_list.append(word)
  30. else:
  31. mixed_list.append(word)
  32.  
  33. print("Lower-case: " + ", ".join(lower_list))
  34. print("Mixed-case: " + ", ".join(mixed_list))
  35. print("Upper-case: " + ", ".join(upper_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement