[docs] ISSUE I FOUND IN TUPLES
Vinay Godaba
godabavinay at gmail.com
Thu Aug 15 12:08:05 EDT 2019
Hello I'm Vinay
recently I started learning python and in this process, I noticed there is
a glitch in tuples.
I don't know whether it's a glitch or not but what I noticed is a list
containing single list can identify inner list as a single element of the
list whereas in tuples a tuple containing single tuple is unable to
identify as a single element unless a comma is specified.
# in case of lists
a = [[1,2,3]]
for i in a:
print(i) # this outputs [1,2,3]
# in case of tuples
a = ((1,2,3))
for i in a:
print(i)
# outputs as
1
2
3
# but if we specify comma
a = ((1,2,3),)
for i in a:
print(i) # this outputs (1,2,3)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20190815/2dc5b14d/attachment.html>
More information about the docs
mailing list