Hi, I have a homework assignment to write a function to compute the nth fibonacci number where n is the value input by the user. For example, if n=6, then the result is 8. I saw a problem like this in one of the forums but i would like some feeback on my code, I know ive probably butchered it cuz im new to this. Any help anyone could give me would be great!
def main()
firstnum = 1
secnum = 1
fibnum = getfibnum()
def getfibnum()
c = int(raw_input("Enter fibonacci numer")
if c == 0:
print "fib number is 0"
if c == 1:
print "fib number is 1"
sum = firstnum + secnum
firstnum = secnum
secnum = sum
print sum
main()
I dont think I'm calling the function correctly, of course I'm sure theres alot wrong w/ this code. My teacher doesnt explain things very well, and when I ask for help he just says "You need to read" he doesnt speak very good english so maybe he just doesnt know how to explain things.