Last updated: Apr 8, 2024
Reading time·6 min

The Python "TypeError: can only concatenate tuple (not "int") to tuple" occurs when we try to concatenate a tuple and an integer.
To solve the error, make sure you haven't got any dangling commas if trying to sum two integers, otherwise declare 2 tuples.

Here is an example of how the error occurs.
my_tuple = 1, 2, 3 my_int = 4 # ⛔️ TypeError: can only concatenate tuple (not "int") to tuple result = my_tuple + my_int
Trying to use the addition (+) operator with a tuple and an integer causes the error.
The error also occurs when working with floating-point numbers.
my_tuple = 1.1, 2.2 my_float = 3.3 # ⛔️ TypeError: can only concatenate tuple (not "float") to tuple result = my_tuple + my_float
We tried to use the addition (+) operator to concatenate a tuple and an integer which caused the error.
If you meant to concatenate two tuples, declare a tuple instead of an int.
my_tuple = 1, 2, 3 my_other_tuple = (4,) result = my_tuple + my_other_tuple print(result) # 👉️ (1, 2, 3, 4)

When you use the addition (+) operator with two tuples, the elements of the tuples get combined into a new tuple.
my_tuple = 4, # 👈️ Comma makes it a tuple print(type(my_tuple)) # 👉️ <class 'tuple'>
Having a trailing comma after the integer declares a tuple.
You can remove the trailing comma to declare an integer.
int_1 = 4 int_2 = 6 result = int_1 + int_2 print(result) # 👉️ 10
If you meant to declare two integers on the same line, use unpacking.
int_1, int_2 = 4, 10 print(int_1) # 👉️ 4 print(int_2) # 👉️ 10
Note that the values on the left have to be exactly as many as the values on the right of the equal sign.
Tuples are constructed in multiple ways:
() creates an empty tuplea, or (a,)a, b or (a, b)tuple() constructorIf you meant to access an element at a specific index in the tuple, use square brackets.
my_tuple = 1, 2, 3 my_int = 10 result = my_tuple[0] + my_int print(result) # 👉️ 11

We accessed the first element in the tuple and added it to an integer.
Note that the values on both sides of the addition operator are integers, so this is allowed.
0, and the last item has an index of -1 or len(my_tuple) - 1.If you aren't sure what type a variable stores, use the built-in type() class.
my_tuple = (1, 2, 3) print(type(my_tuple)) # 👉️ <class 'tuple'> print(isinstance(my_tuple, tuple)) # 👉️ True my_int = 10 print(type(my_int)) # 👉️ <class 'int'> print(isinstance(my_int, int)) # 👉️ True

The type class returns the type of an object.
The isinstance() function
returns True if the passed-in object is an instance or a subclass of the
passed-in class.
The Python "TypeError: can only concatenate tuple (not "str") to tuple" occurs when we try to concatenate a tuple and a string.
To solve the error, make sure that the values are either 2 tuples or 2 strings before concatenating them.

Here is an example of how the error occurs.
my_tuple = ('apple', 'banana') my_str = 'kiwi' # ⛔️ TypeError: can only concatenate tuple (not "str") to tuple result = my_tuple + my_str
We tried to use the addition (+) operator to concatenate a tuple and string which caused the error.
If you meant to concatenate two tuples, declare a tuple instead of a string.
my_tuple = ('apple', 'banana') my_other_tuple = ('kiwi',) result = my_tuple + my_other_tuple print(result) # 👉️ ('apple', 'banana', 'kiwi')
If you meant to concatenate 2 strings, make sure the two variables store a string.
When you declare a variable with a trailing comma, you declare a tuple.
my_tuple = 'apple', # 👈️ note the trailing comma print(my_tuple) # 👉️ ('apple',) print(type(my_tuple)) # 👉️ <class 'tuple'>
If you meant to declare a string, remove the trailing comma.
If you meant to declare two strings on the same line, use unpacking.
str_1, str_2 = ('one', 'two') print(str_1) # 👉️ one print(str_2) # 👉️ two
Tuples are constructed in multiple ways:
() creates an empty tuplea, or (a,)a, b or (a, b)tuple() constructorIf you meant to access an element at a specific index in the tuple, use square brackets.
my_tuple = ('apple', 'banana') my_str = ' is a fruit' result = my_tuple[0] + my_str print(result) # 👉️ "apple is a fruit"
We concatenated the first element in the tuple to a string. Note that the values on both sides of the addition (+) operator are strings, so this is allowed.
Python indexes are zero-based, so the first item in a tuple has an index of 0,
and the last item has an index of -1 or len(my_tuple) - 1.
If you want to print the contents of a tuple, use a formatted string literal.
my_tuple = ('apple', 'banana') my_str = 'are fruits' result = f'{my_tuple} {my_str}' print(result) # 👉️ "('apple', 'banana') are fruits"
f.Make sure to wrap expressions in curly braces - {expression}.
If you aren't sure what type a variable stores, use the built-in type() class.
my_tuple = ('apple', 'banana') print(type(my_tuple)) # 👉️ <class 'tuple'> print(isinstance(my_tuple, tuple)) # 👉️ True my_str = 'are fruits' print(type(my_str)) # 👉️ <class 'str'> print(isinstance(my_str, str)) # 👉️ True
The type class returns the type of an object.
The isinstance() function
returns True if the passed-in object is an instance or a subclass of the
passed-in class.
The Python "TypeError: can only concatenate tuple (not "list") to tuple" occurs when we try to concatenate a tuple and a list.
To solve the error, make sure the two values are of type list or type tuple before concatenating them.

Here is an example of how the error occurs.
my_tuple = ('a', 'b') my_list = ['c', 'd'] # ⛔️ TypeError: can only concatenate tuple (not "list") to tuple result = my_tuple + my_list
We tried to use the addition (+) operator to concatenate a tuple and a list which caused the error.
If you meant to concatenate two tuples, declare a tuple instead of a list, or convert the list to a tuple.
my_tuple = ('a', 'b') my_list = ['c', 'd'] result = my_tuple + tuple(my_list) print(result) # 👉️ ('a', 'b', 'c', 'd')
The tuple class takes an iterable and
returns a tuple object.
We converted the list to a tuple and concatenated the two tuples.
Conversely, you can convert the tuple into a list and concatenate the two lists.
my_tuple = ('a', 'b') my_list = ['c', 'd'] result = list(my_tuple) + my_list print(result) # 👉️ ['a', 'b', 'c', 'd']
The list class takes an iterable and returns a list object.
If you declared the tuple by mistake, tuples are constructed in the following ways:
() creates an empty tuplea, or (a,)a, b or (a, b)tuple() constructorIf you meant to append the tuple to a list, use the append() method.
my_tuple = ('c', 'd') my_list = [('a', 'b')] my_list.append(my_tuple) print(my_list) # 👉️ [('a', 'b'), ('c', 'd')]
The list.append() method adds an item to the end of the list.
The method returns None as it mutates the
original list.
If you aren't sure what type a variable stores, use the built-in type() class.
my_tuple = ('a', 'b') print(type(my_tuple)) # 👉️ <class 'tuple'> print(isinstance(my_tuple, tuple)) # 👉️ True my_list = ['c', 'd'] print(type(my_list)) # 👉️ <class 'list'> print(isinstance(my_list, list)) # 👉️ True
The type class returns the type of an object.
The isinstance() function
returns True if the passed-in object is an instance or a subclass of the
passed-in class.