mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-06 18:49:26 +08:00
Modernize Python 2 code to get ready for Python 3 AGAIN
This commit is contained in:
@ -10,6 +10,8 @@ Example:
|
||||
a=daBcd and b="ABC"
|
||||
daBcd -> capitalize a and c(dABCd) -> remove d (ABC)
|
||||
"""
|
||||
|
||||
|
||||
def abbr(a, b):
|
||||
n = len(a)
|
||||
m = len(b)
|
||||
@ -26,4 +28,4 @@ def abbr(a, b):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print abbr("daBcd", "ABC") # expect True
|
||||
print(abbr("daBcd", "ABC")) # expect True
|
||||
|
@ -7,14 +7,14 @@ import sys
|
||||
|
||||
|
||||
# returns F(n)
|
||||
def fibonacci(n: int): # noqa: F821 This syntax is Python 3 only
|
||||
def fibonacci(n: int): # noqa: E999 This syntax is Python 3 only
|
||||
if n < 0:
|
||||
raise ValueError("Negative arguments are not supported")
|
||||
return _fib(n)[0]
|
||||
|
||||
|
||||
# returns (F(n), F(n-1))
|
||||
def _fib(n: int): # noqa: F821 This syntax is Python 3 only
|
||||
def _fib(n: int): # noqa: E999 This syntax is Python 3 only
|
||||
if n == 0:
|
||||
# (F(0), F(1))
|
||||
return (0, 1)
|
||||
|
Reference in New Issue
Block a user