mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-06 10:31:29 +08:00
Adopt Python >= 3.8 assignment expressions using auto-walrus (#7737)
* Adopt Python >= 3.8 assignment expressions using auto-walrus * updating DIRECTORY.md * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -18,8 +18,7 @@ class Fibonacci:
|
||||
>>> Fibonacci().get(5)
|
||||
[0, 1, 1, 2, 3]
|
||||
"""
|
||||
difference = index - (len(self.sequence) - 2)
|
||||
if difference >= 1:
|
||||
if (difference := index - (len(self.sequence) - 2)) >= 1:
|
||||
for _ in range(difference):
|
||||
self.sequence.append(self.sequence[-1] + self.sequence[-2])
|
||||
return self.sequence[:index]
|
||||
|
Reference in New Issue
Block a user