Problem in understanding Python list comprehensions

前端 未结 6 984
情书的邮戳
情书的邮戳 2021-02-03 13:42

What does the last line mean in the following code?

import pickle, urllib                                                                                                 


        
6条回答
  •  生来不讨喜
    2021-02-03 14:00

    [e[1] * e[0] for e in elt] is a list comprehension, which evaluates to a list itself by looping through another list, in this case elt. Each element in the new list is e[1]*e[0], where e is the corresponding element in elt.

提交回复
热议问题