Modernize Python 2 code to get ready for Python 3 AGAIN

This commit is contained in:
cclauss
2018-01-21 08:25:19 +01:00
parent 54f6d1f6d7
commit 4ee0e620cb
6 changed files with 31 additions and 30 deletions

View File

@ -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

View File

@ -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)