Ciao a tutti.
Ho questa lista:

>>> l=[1,2,3,4,5,6,7,8,9,10,11,12,13,14]
>>> l
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
>>> l.index(8)
7

Tutto regolare fin qui.
Chiedo l'help sulla funzione list.index:

>>> help(l.index)
Help on built-in function index:

index(value, start=0, stop=2147483647, /) method of builtins.list instance
    Return first index of value.

    Raises ValueError if the value is not present.

>>> l.index(8, start=0)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: index() takes no keyword arguments
>>> l.index(8, start=0, stop=9)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: index() takes no keyword arguments

Domanda semplice, perchè non posso utilizzare le keywords specificate nell'help?

Oppure... So che se voglio cercare un valore in una porzione di lista scriverò:

l[3:10].index(8)

Ma il dubbio resta: come mai vengono riportate le keywords start and stop, nell'help?

Grazie in anticipo.

--
Gabriele Battaglia, IZ4APU (Libero)
Sent from TB on Windows 10, Genus Bononiae's computer.
_______________________________________________
Python mailing list
Python@lists.python.it
https://lists.python.it/mailman/listinfo/python

Rispondere a