Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
May 22nd, 2013, 03:46 PM
 CodeHacker1993
Registered User

Join Date: May 2013
Posts: 4
Time spent in forums: 2 h 12 m
Reputation Power: 0
Help with Simple code

Hello I m new to python and i cannot figure out why this error keeps coming up for this code:

Code:
```def fibonacci(number):
if number <= 1:
return number
else:
return fibonacci(number - 1) + fibonacci(number - 2)

user_input = int(input("Enter number: "))
fibonacci_of_user_input = fibonacci(input)
print fibonacci_of_user_input```

the error message is for the return statement in the else. it says

unsupported operand type(s) for -: 'instancemethod' and 'int'

suggestions?

#2
May 22nd, 2013, 05:02 PM
 Marbelous
Registered User

Join Date: Dec 2012
Posts: 21
Time spent in forums: 8 h 31 m 54 sec
Reputation Power: 0
Quote:
 Originally Posted by CodeHacker1993 Hello I m new to python and i cannot figure out why this error keeps coming up for this code: Code: ```def fibonacci(number): if number <= 1: return number else: return fibonacci(number - 1) + fibonacci(number - 2) user_input = int(input("Enter number: ")) fibonacci_of_user_input = fibonacci(input) print fibonacci_of_user_input``` the error message is for the return statement in the else. it says unsupported operand type(s) for -: 'instancemethod' and 'int' suggestions?

fibonacci_of_user_input = fibonacci(input) <<< Shouldn't that be user_input, not input?

#3
May 22nd, 2013, 05:19 PM
 CodeHacker1993
Registered User

Join Date: May 2013
Posts: 4
Time spent in forums: 2 h 12 m
Reputation Power: 0
OMG! yes! thank you. can't believe i didn't see that.

I need to be more vigilant next time...

 Viewing: Dev Shed Forums > Programming Languages > Python Programming > Help with Simple code