Join tuples using the arithmetic plus (+
) sign.
colors_tuple_1 = ("Red", "Blue")
colors_tuple_2 = ("Green",)
colors_tuple_3 = colors_tuple_1 + colors_tuple_2
print(colors_tuple_3)
('Red', 'Blue', 'Green')
In the above example, we are joining two different tuples using the plus (+
) sign and assigning those added tuples to another tuple variable. Accordingly, both tuple items are present in the third join tuple.
Using the multiplication (*
) sign, you can repeat items in a tuple several times.
colors_tuple = ("Red", "Blue")
new_colors_tuple = colors_tuple * 2
print(new_colors_tuple)
('Red', 'Blue', 'Red', 'Blue')
In the output, colors are repeated twice after multiplying the color tuple by two.