Convert list to tuple in Python

The Solution to Convert list to tuple in Python is


It should work fine. Don't use tuple, list or other special names as a variable name. It's probably what's causing your problem.

>>> l = [4,5,6]
>>> tuple(l)
(4, 5, 6)

>>> tuple = 'whoops'   # Don't do this
>>> tuple(l)
TypeError: 'tuple' object is not callable

~ Answered on 2012-10-11 09:15:17


Most Viewed Questions: