A comma denotes an instantiation of a tuple. Most think that it is the parentheses which will define a tuple, but this is incorrect.
#explore the tuple!
single_tuple_error = (10)
print(single_tuple_error)
10
print(type(single_tuple_error))
<class 'int'>
single_tuple = (10, )
print(single_tuple)
(10,)
print(type(single_tuple))
<class 'tuple'>
#no parens!
single_tuple = 10,
print(single_tuple)
(10,)
print(type(single_tuple))
<class 'tuple'>
print(single_tuple[0])
10
print((0, 1, 2) + (3))
TypeError: can only concatenate tuple (not "int") to tuple
print((0, 1, 2) + (3, ))
(0, 1, 2, 3)
funny_tuple = 0, 1, 2 + 3,
print(funny_tuple)
(0, 1, 5)
print(type(funny_tuple))
<class 'tuple'>
funny_tuple = 0, 1, 2, + 3,
print(funny_tuple)
(0, 1, 2, 3)
funny_tuple = 0 - 1, 2, + 3,
print(funny_tuple)
(-1, 2, 3)
print(type(funny_tuple))
<class 'tuple'>
#empty tuples are different and do need parens.
#empty tuple #1
empty_tuple = ()
print(empty_tuple)
()
print(type(empty_tuple))
<class 'tuple'>
#empty tuple #2
empty_tuple = tuple()
print(empty_tuple)
()
print(type(empty_tuple))
<class 'tuple'>
# empty tuple error
empty_tuple_error = (,)
# SyntaxError: invalid syntax