proper use of list comprehensions - python

后端 未结 5 911
予麋鹿
予麋鹿 2020-12-10 04:32

Normally, list comprehensions are used to derive a new list from an existing list. Eg:

>>> a = [1, 2, 3, 4, 5]
>>> [i for i in a if i >          


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 05:02

    From python documentation:

    List comprehensions provide a concise way to create lists. Common applications are to make new lists

    Perhaps you want to learn more about reduce(), filter() and map() functions.

提交回复
热议问题