Method 1
You could apply int()
to all the elements in the list of list:
for x in range(len(list_id)):
list_id[x] = int(list_id[x][0])
Method 2
You could also choose to write it in a fancy list comprehension:
list_id = [int(y) for x in list_id for y in x]
In this case you have to iterate over all the lists inside list_id
and during each iteration you will iterate over the long integer inside those list. This is similar to:
temp = []
for x in list_id:
for y in x:
temp.append(int(x))
list_id = temp
Method 3
You could, if you want, write a user defined function and apply that using map()
function on all the elements of list_id
:
def func(list):
return int(list[0])
list_id = map(func, list_id)
list_id = list(map)
# This line is not required if you just want to iterate over the values.