New GitHub issue #95846 from weipeng1999:<br>
<hr>
<pre>
<!--
If you're new to Python and you're not sure whether what you're experiencing is a bug, the CPython issue tracker is not
the right place to seek help. Consider the following options instead:
- reading the Python tutorial: https://docs.python.org/3/tutorial/
- posting in the "Users" category on discuss.python.org: https://discuss.python.org/c/users/7
- emailing the Python-list mailing list: https://mail.python.org/mailman/listinfo/python-list
- searching our issue tracker (https://github.com/python/cpython/issues) to see if
your problem has already been reported
-->
# Bug report
It is a TypeError caused by following the example "Accessing arguments’ items" in document "https://docs.python.org/3/library/string.html#formatspec" but changing the indices to the negative. Here is my code and result:
```python
>>> coord = (3, 5)
>>> 'X: {0[0]}; Y: {0[1]}'.format(coord) # OK
'X: 3; Y: 5'
>>> 'X: {0[0]}; Y: {0[-1]}'.format(coord) # failed
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: tuple indices must be integers or slices, not str
```
# Your environment
<!-- Include as many relevant details as possible about the environment you experienced the bug in -->
- CPython versions tested on: Python 3.10.6
- Operating system and architecture:
- - OS: Arch Linux x86_64
- - Host: HP ProBook 455 G8 Notebook PC
- - Kernel: 5.19.0-zen1-1-zen
<!--
You can freely edit this text. Remove any lines you believe are unnecessary.
-->
</pre>
<hr>
<a href="https://github.com/python/cpython/issues/95846">View on GitHub</a>
<p>Labels: type-bug</p>
<p>Assignee: </p>