So just for fun I created a small little python script that prompts the user for a number and then prints out that many digits of the Fibonacci sequence. The script that I came up with works, but I can't help but feel its a bit convoluted and there is a probably a better and simpler way to do it.
How could I simplify this script and still have it accomplish the same thing?
def fib(number):
if number == 0:
return 0
elif number == 1:
return 1
else:
numbers = [1, 1]
for i in range(number - 2):
i = numbers[-2] + numbers[-1]
numbers.append(i)
return numbers
x = int(raw_input("How many digits of the Fibonacci sequence would you like to see?"))
Results = fib(x)
print Results