1a = ('tree', 'plant', 'bird')
2b = ('ocean', 'fish', 'boat')
3# a and b are both tuples
4
5c = a + b
6# c is a tuple: ('tree', 'plant', 'bird', 'ocean', 'fish', 'boat')
1def add_elements_to_tuple(initial_tuple: tuple= tuple(), *args)-> tuple:
2 initial_tuple= tuple(initial_tuple)
3 initial_tuple+= args
4 return initial_tuple
5
6def add_elements_to_tuple(initial_tuple: tuple= tuple(), *args)-> tuple:
7 if type(initial_tuple)!= tuple:
8 raise TypeError("you have to input a tuple in the first parametere of this function!!")
9 initial_tuple+= args
10 return initial_tuple
11
12 # I don't have to convert the args to a tuple because when arguments are
13 # passed in with the asterisk the type is by default a tuple
14
15# the first version does not raise errors in the majority of cases
16# the second one is more likely to raise an error
17# choose the one that you are more comfortable with