mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
Add tests without modifying code (#10740)
* Contributes to #9943 Added doctest to largest_of_very_large_numbers.py Added doctest to word_patterns.py Added doctest to onepad_cipher.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Contributes to #9943 Added doctest to maths/largest_of_very_large_numbers.py Added doctest to strings/word_patterns.py Added doctest to ciphers/onepad_cipher.py * Add tests without modifying code #10740 Added test to maths/largest_of_very_large_numbers Added test to strings/word_patterns.py Added test to ciphers/onepad_cipher.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,11 +1,32 @@
|
||||
def get_word_pattern(word: str) -> str:
|
||||
"""
|
||||
Returns numerical pattern of character appearances in given word
|
||||
>>> get_word_pattern("")
|
||||
''
|
||||
>>> get_word_pattern(" ")
|
||||
'0'
|
||||
>>> get_word_pattern("pattern")
|
||||
'0.1.2.2.3.4.5'
|
||||
>>> get_word_pattern("word pattern")
|
||||
'0.1.2.3.4.5.6.7.7.8.2.9'
|
||||
>>> get_word_pattern("get word pattern")
|
||||
'0.1.2.3.4.5.6.7.3.8.9.2.2.1.6.10'
|
||||
>>> get_word_pattern()
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
TypeError: get_word_pattern() missing 1 required positional argument: 'word'
|
||||
>>> get_word_pattern(1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
AttributeError: 'int' object has no attribute 'upper'
|
||||
>>> get_word_pattern(1.1)
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
AttributeError: 'float' object has no attribute 'upper'
|
||||
>>> get_word_pattern([])
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
AttributeError: 'list' object has no attribute 'upper'
|
||||
"""
|
||||
word = word.upper()
|
||||
next_num = 0
|
||||
|
Reference in New Issue
Block a user