Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ---------- tasks/most_wanted.py ---------------
- LETTERS = "abcdefghijklmnopqrstuvwxyz"
- def checkio(text: str) -> str:
- text = text.lower()
- item = "a"
- val = text.count(item)
- for _item in LETTERS:
- _val = text.count(_item)
- if val < _val:
- item = _item
- val = _val
- return item
- def checkio_max(text: str) -> str:
- return max(LETTERS, key=text.lower().count)
- # -------- tests/test_most_wanted.py ----------------
- import pytest
- from tasks.most_wanted import checkio, checkio_max
- @pytest.mark.parametrize("func", [checkio, checkio_max])
- @pytest.mark.parametrize(["text", "res"], [
- ["Hello World!", "l"],
- ["How do you do?", "o"],
- ["One", "e"],
- ["Oops!", "o"],
- ["AAaooo!!!!", "a"],
- ["abe", "a"],
- ["a" * 9000 + "b" * 1000, "a"],
- ["oooAAa!!!!", "a"],
- ])
- def test_most_wanted(func, text, res):
- assert func(text) == res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement