I have just started to learn python and following the docs on tuples, I came across this snippet,
>>> empty = () >>> singleton = 'hello', # <-- note trailing comma >>> len(empty) 0 >>> len(singleton) 1 >>> singleton ('hello',) Following this I ran following snippet,
>>> foo=1,2,3, >>> len(foo) 3 >>> foo (1, 2, 3) Why does singleton prints with an trailing comma , where as foo seems to trim it ?
('hello')wouldn't be a tuple.