0

I have a list like this:

df = ['1 90 80', '2 70 50', '3 60 60']

and I want to convert the list like this:

result = [[1, 90, 80], [2, 70, 50], [3, 60, 60]]

I tried with for loop and append() function, but I found that I can not append list as it is.

Is there any way to solve this? Thanks

wjandrea
  • 23,210
  • 7
  • 49
  • 68
  • 1
    You can study the duplicate links. If you want a quick answer, `output = [[int(n) for n in s.split()] for s in df]` will do. – j1-lee Feb 17 '22 at 06:06

0 Answers0