I would like to provide a different approach to the problem but also
I take this opportunity to remember that day by day python 2 is closer to being declared
obsolete, and he should have delegated his role in the
learning and creating new code to python 3.
The approach I propose involves generating the complete list of values
from the beginning and then you can simply check if that list contains
the number searched.
To generate the list you can use a generating function like the
next:
def generar_fibo_mayores_a_10(limite):
a, b = 13, 21
while a < limite:
yield a
a, b = b, a + b
Through which you can generate elements until you reach a "limit"
established by its sole argument. In the case of this problem, the limit
would be 100, so the complete list can be generated with:
serie = [f for f in generar_fibo_mayores_a_10(limite=100)]
Now if we want to know if a specific number belongs to the series, it's enough
with doing:
if numero in serie:
print('Si pertenece')
else:
print('No pertenece')
After all, it would be practically the same if you were only going to consult a
number as in this case, although it could be much more efficient in case of
require to do the process several times.
In case it is not clear how to integrate these ideas in your code, here I leave you
the complete example:
def generar_fibo_mayores_a_10(limite):
a, b = 13, 21
while a < limite:
yield a
a, b = b, a + b
serie = [f for f in generar_fibo_mayores_a_10(limite=100)]
numero = int(input('Digite un número de dos dígitos: '))
if 9 < numero <= 99:
print('El número', ('si' if numero in serie else 'no'),
'pertenece a la serie de fibonacci')
else:
print('Debe ingresar un número de dos dígitos')