0

How can I remove the list inside list(Double Square Brackets) and make it as list of type integer.

I tried choosing one element at a time:

enter code here
x = [['19'], ['19', '21']]
x = (int(x) for x in x)

But instead it results in <generator object>.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
SwapB
  • 11
  • 1

2 Answers2

0

If you add the lists together you will get your desired result like:

Code:

sum(x, [])

Test Code:

x = [['19'], ['19', '21']]

print(sum(x, []))

Results:

['19', '19', '21']
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
0

All you need is:

final_list = [i for sub_list in x for i in sub_list]
Austin
  • 25,759
  • 4
  • 25
  • 48