Getting error in adding tuples
Title
Question
why am i getting an error?
In [27]: person_tuple=(17,"Ram",56.8)
In [28]: t2=("Student")
In [29]: person_tuple
Out[29]: (17, 'Ram', 56.8)
In [30]: person_tuple + t2
---------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-30-3714b9ddcd0d> in <module>
----> 1 person_tuple + t2
TypeError: can only concatenate tuple (not "str") to tuple
Python-3.4.3 Sequence-datatypes 06-07 min 10-20 sec
Answers:
In order for t2 variable to be recognized as a tuple you have to add a comma separator at the end (after "student")
Login to add comment