What you mean to do is y.index('2'), rather than y.index['2']. Call
the index method of the list, rather than try to use index as if it was
itself a list.
--
http://mail.python.org/mailman/listinfo/python-list
What you mean to do is y.index('2'), rather than y.index['2']. Call
the index method of the list, rather than try to use index as if it was
itself a list.
--
http://mail.python.org/mailman/listinfo/python-list
"questions?" wrote:
>I want to do list index function.
y=['1','2','3','4']
y
> ['1', '2', '3', '4']
y.index['2']
make that:
>>> y.index('2')
--
http://mail.python.org/mailman/listinfo/python-list
sorry, I realized the problem already. sorry for the confusion.
THanks for the answer!!!
--
http://mail.python.org/mailman/listinfo/python-list
questions? wrote:
> I want to do list index function.
y=['1','2','3','4']
y
> ['1', '2', '3', '4']
y.index['2']
> Traceback (most recent call last):
> File "", line 1, in ?
> TypeError: unsubscriptable object
>
> It works with y=[1,2,3,4]. Anyone has any hint, what's the reason
>
I want to do list index function.
>>> y=['1','2','3','4']
>>> y
['1', '2', '3', '4']
>>> y.index['2']
Traceback (most recent call last):
File "", line 1, in ?
TypeError: unsubscriptable object
It works with y=[1,2,3,4]. Anyone has any hint, what's the reason
here?
thanks
--
http://mail.pytho