Considerando o código em python a seguir:
|
def funcao(numeros, limite): i = 0 while i < len(numeros): if numeros[i] > limite: return i i += 1 return -1 |
As chamadas de função:
funcao([1, 10, 20, 30, 50, 100], 10);
funcao([1, 10, 20, 30, 50, 100], 200);
funcao([1, 10, 20, 30, 50, 100], 30);
Retornam, respectivamente: