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: Tuple Slice Bug
Type: behavior Stage: resolved
Components: Build Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: p.saisathvikrao, serhiy.storchaka
Priority: normal Keywords:

Created on 2020-11-30 08:22 by p.saisathvikrao, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg382118 - (view) Author: Sathvik Rao Poladi (p.saisathvikrao) Date: 2020-11-30 08:22
>>>a=1,2,3,4
>>>a[1:2]
(2,)

Expected output -> (2)
bug -> ,
msg382127 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-11-30 08:45
(2) is not a tuple. It is just a number 2. To make a tuple containing a single item you need to use special syntax: add a comma to that item. Parenthesis are optional.

>>> (2)
2
>>> (2,)
(2,)
>>> 2,
(2,)
History
Date User Action Args
2022-04-11 14:59:38adminsetgithub: 86676
2020-11-30 08:45:13serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg382127

resolution: not a bug
stage: resolved
2020-11-30 08:22:38p.saisathvikraocreate