I just want to make tuple to using list so,
list1 = [1,2]
a = tuple(list1)
I used this code but it's error..
TypeError: 'tuple' object is not callable
Why don't make tuple?
I just want to make tuple to using list so,
list1 = [1,2]
a = tuple(list1)
I used this code but it's error..
TypeError: 'tuple' object is not callable
Why don't make tuple?
As you can see in this question Convert list to tuple in Python
You by sure called a variable like list
or tuple
, those words are built in types and can be redefined, which is a great source of errors
by example:
list = [1,3]
tuple = (2,3)
only this peace of code, works fine, but if you try to do
list = [1,3]
tuple = (2,3)
a = tuple(list)
you will get the error
TypeError: 'tuple' object is not callable
other posible scenario:
list = [1,2,3,4]
print(list)
$[1,2,3,4]
but:
list = [1,2,3,4]
print(list)
other_list = list((1,2,3,4))
print(other_list)
TypeError: 'list' object is not callable
because you redefined list
and now is an object, the object [1,2,3,4]
the solution is simple, rename your variables, example:
lst = [1,3]
tpl = (4,5)
a = tuple(lst)
print(a)
$(1,3)