1

Hi I have a list where each element is one element list: https://i.stack.imgur.com/JSH9j.png

[['2199822281'], ['2199822390'], ['2199822392'], ['2199822369'], ['2199822370'], ['2199822284'], ['2199822281']]

What I want is to convert it to a list of ints in python how do I do that?

DESIRED OUTPUT

[2199822281, 2199822390 ...,2199822281]

Please refer to the image

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • If L1 is your list, L2 = reduce(lambda a,b : a+b , L1) followed by map(int, L2) will give your desired result, but there are several alternatives, search for them in SO archives. – Sailendra Pinupolu Jun 17 '16 at 03:05

2 Answers2

1

This should do the trick:

x = [int(i[0]) for i in list]

Where list is the name of your list of lists above and x is you output list.

nbryans
  • 1,507
  • 17
  • 24
0

Following is another way

import operator
x = [['2199822281'], ['2199822390'], ['2199822392'], ['2199822369'], ['2199822370'], ['2199822284'], ['2199822281']]
print map(int, reduce(operator.add, x))
Jerome Anthony
  • 7,823
  • 2
  • 40
  • 31