declare tuple code example
Example 1: tuples in python
my_tuple = 3, 4.6, "dog"
print(my_tuple)
# tuple unpacking is also possible
a, b, c = my_tuple
print(a) # 3
print(b) # 4.6
print(c) # dog
Example 2: tuples in python
my_tuple = ("hello")
print(type(my_tuple)) # <class 'str'>
# Creating a tuple having one element
my_tuple = ("hello",)
print(type(my_tuple)) # <class 'tuple'>
# Parentheses is optional
my_tuple = "hello",
print(type(my_tuple)) # <class 'tuple'>
Example 3: make a tuple
#you can put a lotta stuff in tuples
tup = ("string", 2456, True)
Example 4: how to make a tuple
thistuple = ("apple", "banana", "cherry")
print(thistuple)