This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ValueError using index on tuple is not showing the tuple value
Type: behavior Stage: resolved
Components: Versions: Python 3.8
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Non-informative error message in index() and remove() functions
View: 13349
Assigned To: Nosy List: tuxskar, xtreak
Priority: normal Keywords:

Created on 2020-01-30 07:41 by tuxskar, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg361016 - (view) Author: Oscar (tuxskar) Date: 2020-01-30 07:41
When trying to retrieve the index of an element that is not in a tuple the error message of ValueError is not showing the value looking for but instead a static message tuple.index(x): x not in tuple

>>> b = (1, 2, 3, 4)
>>> b.index(5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: tuple.index(x): x not in tuple

I would expect something like what happen in lists where the element (5 in this case) is showed on the ValueError.
>>> a = [1, 2, 3, 4]
>>> a.index(5)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: 5 is not in list
msg361025 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2020-01-30 09:03
This is a duplicate of issue33560. See also issue13349 which is the original duplicate.
History
Date User Action Args
2022-04-11 14:59:26adminsetgithub: 83680
2020-01-30 09:03:41xtreaksetstatus: open -> closed

superseder: Non-informative error message in index() and remove() functions
nosy: + xtreak

messages: + msg361025
type: behavior
resolution: duplicate
stage: resolved
2020-01-30 07:41:48tuxskarcreate