I have a problem about making a fibonacci sequence to a list, I\'m just new to python someone help me please.
This is my code. I know this is looking wrong or somet
You can use below code, your problem can be solve in just one line. what are we doing is appending the
fib_nums
till your given limit i.e.,
700
and then adding the
fib_nums
with the second list which is of zero length which explicitly we doing, because it is containing
None
values, that we don't required.
#defining variable
fib_nums = [0, 1]
#just one line code
fib_nums = fib_nums + [fib_nums.append(fib_nums[i-1]+fib_nums[i-2]) for i in range(2,700)]*0
#printing the series
print (fib_nums)