Problem
The problem here is that here:
d = raw_input("How many numbers would you like to display")
you assign string from the input into the d variable, and later you pass it to range(). But range() expects expects integers, not strings, and Python does not convert it automatically (it leaves conversion to you).
Solution
The solution is to convert result of raw_input() into int like that:
d = int(raw_input("How many numbers would you like to display"))
and everything will work unless you provide non-integer.
But there is better (shorter, more efficient, more encapsulated) method of generating Fibonacci numbers (see below).
Better method of generating Fibonacci numbers
I believe this is the best (or nearly the best) solution:
def fibo(n):
a, b = 0, 1
for i in xrange(n):
yield a
a, b = b, a + b
This is a generator, not a simple function. It is very efficient, its code is short and does not print anything, but you can print its result like that:
>>> for i in fibo(20):
print i,
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181
or convert it into a list like that:
>>> list(fibo(20))
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181]
Applying the above in your case
After applying the above to your code, it could look like this:
def fibo(n):
a, b = 0, 1
for i in xrange(n):
yield a
a, b = b, a + b
d = int(raw_input("How many numbers would you like to display"))
for i in fibo(d):
print i
Does it answer your question?
0, not1, correct example