+91 81900 98289

Join Tuples

This Join Tuples lesson is for a beginner. Read the short notes, run each example, then change one name or number and run it again.

Adding two tuples builds a new tuple. The originals stay as they were.

A one-item tuple needs a trailing comma. Without it, parentheses only group an expression.

Example 1: Start here

(\"Python\") is a string. (\"Python\",) is a tuple.

left = ("Python",) # a tuple; a fixed group of values right = ("SQL", "Git") # a tuple; a fixed group of values print(left + right)

Example 2: Add tuples

Plus returns a new tuple. Tuples themselves cannot grow with append.

print(("Python",) + ("SQL", "Git")) # plus joins text; use str() for a number

Example 3: Repeat a tuple

The comma after ha keeps it a one-item tuple.

print(("ha",) * 3) # print writes this; the quotes are not shown

Example 4: Build from a list

tuple() copies the items into a tuple.

print(tuple(["Python", "SQL"])) # print writes this; the quotes are not shown
(\"Python\") is a string. (\"Python\",) is a tuple.
Call Now 81900 98289