Converting List Comprehensions to For Loops in Python

前端 未结 4 1804
轻奢々
轻奢々 2020-12-02 00:51

I understand the importance of list comprehensions, but do not understand their inner-workings, thus am not able to understand them in simpler terms such as I would a for lo

4条回答
  •  再見小時候
    2020-12-02 01:51

    Question:

    How could I change this to a for loop?

    li = [row[index] for row in outer_list]
    

    Answer:

    li = []
    for row in outer_list:
       li.append(row[index])
    

提交回复
热议问题