mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
Make some ruff fixes (#8154)
* Make some ruff fixes * Undo manual fix * Undo manual fix * Updates from ruff=0.0.251
This commit is contained in:
@@ -27,10 +27,7 @@ class Trie:
|
||||
def _elements(self, d: dict) -> tuple:
|
||||
result = []
|
||||
for c, v in d.items():
|
||||
if c == END:
|
||||
sub_result = [" "]
|
||||
else:
|
||||
sub_result = [c + s for s in self._elements(v)]
|
||||
sub_result = [" "] if c == END else [(c + s) for s in self._elements(v)]
|
||||
result.extend(sub_result)
|
||||
return tuple(result)
|
||||
|
||||
|
||||
@@ -38,10 +38,7 @@ def check_anagrams(first_str: str, second_str: str) -> bool:
|
||||
count[first_str[i]] += 1
|
||||
count[second_str[i]] -= 1
|
||||
|
||||
for _count in count.values():
|
||||
if _count != 0:
|
||||
return False
|
||||
return True
|
||||
return all(_count == 0 for _count in count.values())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -30,10 +30,7 @@ def is_palindrome(s: str) -> bool:
|
||||
# with the help of 1st index (i==n-i-1)
|
||||
# where n is length of string
|
||||
|
||||
for i in range(end):
|
||||
if s[i] != s[n - i - 1]:
|
||||
return False
|
||||
return True
|
||||
return all(s[i] == s[n - i - 1] for i in range(end))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -43,7 +43,7 @@ def snake_to_camel_case(input_str: str, use_pascal: bool = False) -> str:
|
||||
|
||||
initial_word = "" if use_pascal else words[0]
|
||||
|
||||
return "".join([initial_word] + capitalized_words)
|
||||
return "".join([initial_word, *capitalized_words])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user