Reputation: 435
I have a list of tuples like the following
list=[(1,2),(3,4),(5,6)]
now I need to add them to a new tuple tup=()
my resultant tuple should look like tup=((1,2),(3,4),(5,6))
I tried using the following code:
for each in list:
tup=tup,each
the result is
(((), (627, 2)), (627, 3))
Can someone help me solving this?
Upvotes: 1
Views: 54
Reputation: 107287
You just need to convert with tuple
function :
>>> my_list=[(1,2),(3,4),(5,6)]
>>> tuple(my_list)
((1, 2), (3, 4), (5, 6))
note : dont use the built-in functions name or python keywords as your structure and variables name!
Upvotes: 6