Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # --------------- tasks/three_words.py ------------------
- def checkio(words: str) -> bool:
- words = words.split()
- for index in range(len(words) - 2):
- three_words = words[index:index+3]
- if all_words_are_text(three_words):
- return True
- return False
- def all_words_are_text(words: list) -> bool:
- for word in words:
- if not word.isalpha():
- return False
- return True
- # -------------------- tests/test_three_words.py -------------------
- import pytest
- from tasks.three_words import checkio, all_words_are_text
- @pytest.mark.parametrize(["words", "expected"], [
- ["Hello World hello", True],
- ["He is 123 man", False],
- ["1 2 3 4", False],
- ["bla bla bla bla", True],
- ["Hi", False],
- ])
- def test_three_words(words, expected):
- assert checkio(words) == expected
- @pytest.mark.parametrize(["words", "res"], [
- [["how", "are", "you"], True],
- [["how", "1", "you"], False],
- [["2", "are", "you"], False],
- [["5", "2", "4"], False],
- ])
- def test_all_words_are_text_check(words, res):
- assert all_words_are_text(words) == res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement