A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-April/088135.html below:

[Python-Dev] Getting values stored inside sets

[Python-Dev] Getting values stored inside setsAntoine Pitrou solipsis at pitrou.net
Fri Apr 3 17:07:28 CEST 2009
Steven D'Aprano <steve <at> pearwood.info> writes:
> 
> That's hardly unusual in Python.
> 
> >>> alist = [0, 1, 2, 3, 4]
> >>> 3.0 in alist
> True
> >>> alist[3.0]
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: list indices must be integers

Your example is wrong:

>>> alist = [0, 1, 2, 3, 4]
>>> alist.index(3.0)
3
>>> alist[alist.index(3.0)]
3

Regards

Antoine.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4