[mypy] Fix type annotations for strings (#4637) · zinating/algorithms-python@20a4fdf · GitHub
Skip to content

Commit 20a4fdf

Browse files
authored
[mypy] Fix type annotations for strings (TheAlgorithms#4637)
* Fix mypy error for can_string_be_rearranged_as_pal * Fix mypy error for levenshtein_distance.py * Fix mypy error for word_patterns.py * Fix mypy error for word_occurrence.py
1 parent 9cb5760 commit 20a4fdf

4 files changed

Lines changed: 4 additions & 4 deletions

File tree

strings/can_string_be_rearranged_as_palindrome.py

Lines changed: 1 addition & 1 deletion

strings/levenshtein_distance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def levenshtein_distance(first_word: str, second_word: str) -> int:
4141
if len(second_word) == 0:
4242
return len(first_word)
4343

44-
previous_row = range(len(second_word) + 1)
44+
previous_row = list(range(len(second_word) + 1))
4545

4646
for i, c1 in enumerate(first_word):
4747

strings/word_occurrence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def word_occurence(sentence: str) -> dict:
1414
>>> dict(word_occurence("Two spaces"))
1515
{'Two': 1, 'spaces': 1}
1616
"""
17-
occurrence = defaultdict(int)
17+
occurrence: dict = defaultdict(int)
1818
# Creating a dictionary containing count of each word
1919
for word in sentence.split():
2020
occurrence[word] += 1

strings/word_patterns.py

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)