Simplify code by dropping support for legacy Python (#1143)

* Simplify code by dropping support for legacy Python

* sort() --> sorted()
This commit is contained in:
Christian Clauss
2019-08-19 15:37:49 +02:00
committed by GitHub
parent 32aa7ff081
commit 47a9ea2b0b
145 changed files with 367 additions and 976 deletions

View File

@ -25,12 +25,6 @@ What is the index of the first term in the Fibonacci sequence to contain 1000
digits?
"""
try:
xrange # Python 2
except NameError:
xrange = range # Python 3
def fibonacci(n):
if n == 1 or type(n) is not int:
return 0
@ -38,7 +32,7 @@ def fibonacci(n):
return 1
else:
sequence = [0, 1]
for i in xrange(2, n + 1):
for i in range(2, n + 1):
sequence.append(sequence[i - 1] + sequence[i - 2])
return sequence[n]