I have a list in this format:
a =[["1","2"], ["3","4"]]
I need to turn it into this format:
a =[("1","2"), ("3","4")]
thank you
I have a list in this format:
a =[["1","2"], ["3","4"]]
I need to turn it into this format:
a =[("1","2"), ("3","4")]
thank you
use tuple
and list comprehension :
>>> a=[tuple(i) for i in a]
>>> a
[('1', '2'), ('3', '4')]
Also you can use map
function (less performance than list-comprehension):
>>> a=map(tuple,a)
>>> a
[('1', '2'), ('3', '4')]
Another solution, you can use map
>>> a =[["1","2"], ["3","4"]]
>>> map(tuple, a)
[('1', '2'), ('3', '4')]