Python TypeError: can only concatenate tuple (not set) to tuple














































Python TypeError: can only concatenate tuple (not set) to tuple



Python TypeError : can only concatenate tuple (not "set") to tuple


TypeError raises when an operation or function is attempted that is invalid for the specified data type.

For example:  Let's see what happens when a tuple is concatenated to a set.




Here we are supposed to add tuple to a set, but Python throws a TypeError.


To get rid of this Error we have to insert 'tuple'( ) in place of 'set( '{ }')'.


The output will be:


Exceptions are convenient in many ways for handling errors and special conditions in a program. When you think that you have a code which can produce an error then you can use exception handling.

An Exception is an error that happens during execution of the program.  When that error occurs, python generate an exception that can be handled.


The result of the above program will be:





Comments