Python add item to the tuple
I have some object.ID-s which I try to store in the user session as tuple. When I add first one it works but tuple looks like (u'2',) but when I try to add new one using mytuple = mytuple + new.id got error can only concatenate tuple (not "unicode") to tuple . You need to make the second element a 1-tuple, eg: a = ('2',) b = 'z' new = a + (b,) Since Python 3.5 ( PEP 448 ) you can do unpacking within a tuple, list set, and dict: a = ('2',) b = 'z' new = (*a, b) kiriloff From tuple to list to tuple : a = ('2',) b = 'b' l = list(a) l.append(b) tuple(l) Or with a longer list of items to append a =