Change occurrences of str.format to f-strings (#4118)

* f-string update rsa_cipher.py

* f-string update rsa_key_generator.py

* f-string update burrows_wheeler.py

* f-string update non_recursive_segment_tree.py

* f-string update red_black_tree.py

* f-string update deque_doubly.py

* f-string update climbing_stairs.py

* f-string update iterating_through_submasks.py

* f-string update knn_sklearn.py

* f-string update 3n_plus_1.py

* f-string update quadratic_equations_complex_numbers.py

* f-string update nth_fibonacci_using_matrix_exponentiation.py

* f-string update sherman_morrison.py

* f-string update levenshtein_distance.py

* fix lines that were too long
This commit is contained in:
CarsonHam
2021-02-22 23:53:49 -06:00
committed by GitHub
parent f680806894
commit 61f3119467
14 changed files with 38 additions and 39 deletions

View File

@ -49,7 +49,7 @@ class SegmentTree:
:param arr: list of elements for the segment tree
:param fnc: commutative function for combine two elements
>>> SegmentTree(['a', 'b', 'c'], lambda a, b: '{}{}'.format(a, b)).query(0, 2)
>>> SegmentTree(['a', 'b', 'c'], lambda a, b: f'{a}{b}').query(0, 2)
'abc'
>>> SegmentTree([(1, 2), (2, 3), (3, 4)],
... lambda a, b: (a[0] + b[0], a[1] + b[1])).query(0, 2)

View File

@ -475,11 +475,13 @@ class RedBlackTree:
from pprint import pformat
if self.left is None and self.right is None:
return "'{} {}'".format(self.label, (self.color and "red") or "blk")
return f"'{self.label} {(self.color and 'red') or 'blk'}'"
return pformat(
{
"%s %s"
% (self.label, (self.color and "red") or "blk"): (self.left, self.right)
f"{self.label} {(self.color and 'red') or 'blk'}": (
self.left,
self.right,
)
},
indent=1,
)

View File

@ -20,8 +20,8 @@ class _DoublyLinkedBase:
self._next = link_n
def has_next_and_prev(self):
return " Prev -> {}, Next -> {}".format(
self._prev is not None, self._next is not None
return (
f" Prev -> {self._prev is not None}, Next -> {self._next is not None}"
)
def __init__(self):