lst = [1, 2, 3, 4, 5] def maketup(lst): cur_item = lst[-1] lst = lst[:-1] if len(lst): return maketup(lst), cur_item else: return cur_item
print maketup(lst) ((((1, 2), 3), 4), 5) But I'm confused as to what you mean by : > Among them, I want to pair up terminals until there is only one left > at the end. One what? one pair?, one terminal meaning one number? -- http://mail.python.org/mailman/listinfo/python-list