Tuple of one element in Python
A tuple can consist of only one element.
However, when working with such tuples, there is a nuance: after the element, you must put a hanging comma:
pythontpl = ('a',)
If you leave the element without a comma, the brackets will denote mathematical grouping brackets:
pythontest1 = ('a',) # tuple
test2 = ('a') # string
test3 = (1) # number
If you create a tuple of several elements, then you don’t need to put a comma after the last one (but you can):
pythontpl = ('a', 'b', 'c')
Задание 1
Given a variable:
pythontst = ('1')
Tell me what type of data it is.
Задание 2
Given a variable:
pythontst = (1,)
Tell me what type of data it is.
Задание 3
Given a variable:
pythontst = (True)
Tell me what type of data it is.