views:

89

answers:

2

My apologies in advance should I butcher any Python vocabulary, this is my first programming class and we are not permitted to post or share our code. I will do my best to explain the problem.

I am defining my function as variable one and variable two. I then gave values to both variables. I used a for statement with a range value; created a new variable to handle the sum of the two previous Fib. values; and redefine my original variables for the program to iterate through until I reached my maximum.

I am receiving an error message: <function appendNextFib at 0x01FB14B0>

I cannot find an explanation for what the error message means. From either the message itself or from what I have written, does the fatal flaw jump out at anyone?

+3  A: 

To invoke your function, you have to use parens: appendNextFib(). It looks like you simply used appendNextFib, which would show you its value, which is that function object.

Ned Batchelder
Two hours I have sat here, and it was that simple. Thank you!
Linda
Aren't learning curves fun? ;-)
Benjamin Cox
If you really want to thank me, accept the answer! Linda? D'oh... :(
Ned Batchelder
Had to find the "boy am I happy to accept the answer button" ;)Lesson learned, mistake not to be repeated.Seriously....thank you all for such quick replies.
Linda
A: 

While I personally think you may be stressing too much about the sharing of your code, a recursive solution to the problem is a lot more logical and would help you out if your issue is caught up in the declaration of variables.

the recursive solution would look like

def fib(n):
    base case:
         return val
    base case:
         return val
    else:
         return recursive call

Without trying to give too much away I hope this makes sense.

edit: just read that you had included the function id in your initial post, sorry for the confusion this may cause

dagoof