KnowledgeBoat Logo
|

Computer Science

Consider the following code and find out the error:

T1 = ('A')
T2 = ('B', 'C', 3)
T3 = T1 + T2

Python Tuples

3 Likes

Answer

The code raises an error because T1 is not recognized as a tuple but as a string due to the missing comma. A single-element tuple needs a trailing comma, like T1 = ('A',). Therefore, T1 is a string, and concatenating a string with a tuple using T1 + T2 is not allowed, causing the error.

Answered By

1 Like


Related Questions