Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import re
  2. def checkio(words: str) -> bool:
  3. str_ = words.split()
  4. sum_ = 0
  5. for i in str_:
  6. result = re.findall(r'[w*']+', i)
  7. if len(result)!=0 and result != []:
  8. sum_ = sum_+ 1
  9. if sum_ >= 3:
  10. return True
  11. else:
  12. return False
  13.  
  14.  
  15. #These "asserts" using only for self-checking and not necessary for auto-testing
  16. if __name__ == '__main__':
  17. print('Example:')
  18. print(checkio("Hello World hello"))
  19.  
  20. assert checkio("Hello World hello") == True, "Hello"
  21. assert checkio("He is 123 man") == False, "123 man"
  22. assert checkio("1 2 3 4") == False, "Digits"
  23. assert checkio("bla bla bla bla") == True, "Bla Bla"
  24. assert checkio("Hi") == False, "Hi"
  25. print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
  26.  
  27. for i in str_:
  28. если слово: # if not i.isdigit(): или регуляркой
  29. sum_ = sum_+ 1
  30. if sum_ >= 3:
  31. return True
  32. else:
  33. sum_ = 0
  34. return False
  35.  
  36. import itertools as it
  37.  
  38. def checkit(a: str):
  39. if len(list(it.takewhile(lambda x: not x.isnumeric(), a.split())))>2:
  40. return True
  41. else:
  42. return False
  43.  
  44. checkit('hello1 1 world hello 2') #False
  45. checkit('hello1 world hello 2') #True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement