Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. raw_list = ['Apple FResh', 'Americano', 'animator Bob', 'tea$.sugar Menu', 'tea And Sugar', 'hello Tom And jeRRy',
  2. '6 Hours', 'banana']
  3. filtered = []
  4.  
  5.  
  6. def list_filter():
  7. is_end = False
  8. for string in raw_list:
  9. words = string.split(' ')
  10. print 'words', words
  11. for i, s in enumerate(words):
  12. if s.isdigit():
  13. is_end = True
  14. print 'is digit', s
  15. break
  16. if len(words) > 1 and not s[0].isupper():
  17. is_end = True
  18. break
  19. if i > 0:
  20. if s[0].isupper():
  21. continue
  22. else:
  23. is_end = True
  24. print 'not upper', s
  25. break
  26. if is_end:
  27. break
  28. else:
  29. filtered.append(string)
  30.  
  31.  
  32. list_filter()
  33. print filtered
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement