Feb-14-2020, 12:28 AM
That is, well, kinda screwed up. Sorry. Here:
fbNext can be initialized as [0,1]
Any time you see range(len(xxx)) re-evaluate. That is almost always wrong. You want the range of fibLimit, not anything to do with fbNext.
I wrote it so you append to the fbNext list as that seemed to be your preference, fixed the syntax and code.
fibLimit= int(input('Enter how many Fibonacci numbers you would like to print = ')) fbNext = [0,1] for i in range(fibLimit): if i<2 : print(fbNext[i]) else: fbNext.append(fbNext[i-2] + fbNext[i - 1]) print(fbNext[i])fibLimit should be int() rather than eval()
fbNext can be initialized as [0,1]
Any time you see range(len(xxx)) re-evaluate. That is almost always wrong. You want the range of fibLimit, not anything to do with fbNext.
I wrote it so you append to the fbNext list as that seemed to be your preference, fixed the syntax and code.