Most elegant way to modify elements of nested lists in place

前端 未结 7 718
囚心锁ツ
囚心锁ツ 2020-12-14 01:20

I have a 2D list that looks like this:

table = [[\'donkey\', \'2\', \'1\', \'0\'], [\'goat\', \'5\', \'3\', \'2\']]

I want to change the la

相关标签:
7条回答
  • 2020-12-14 02:05
    for row in table:
        row[1:] = [int(c) for c in row[1:]]
    

    Does above look more pythonic?

    0 讨论(0)
提交回复
热议问题