Python Tutorial | List Comprehension | Substitute for Lambda map filter and reduce function



In this Python Programming video tutorial you will learn about List comprehension in detail with example.

List is nothing but “it is the group of different types of elements”.And there are different ways to create list in Python, but one of the easiest, fastest and elegant way is using list comprehension.

List Comprehension is the perfect substitute for lambda map filter and reduce function . If you are not comfortable with the syntax of those function then you can use list comprehension instead of them.

For more free tutorials on computer programming

Nguồn: https://benjaminjcohen.com/

Xem thêm bài viết khác: https://benjaminjcohen.com/cong-nghe/

6 Comments

  1. madam, please explain below code how the answer is getting '1'

    values = [[3, 4, 5, 1], [33, 6, 1, 2]]

    v = values[0][0]

    for lst in values:

    for element in lst:

    if v > element:

    v = element

    print(v)

  2. Hi mam,
    I have a doubt

    for i in range(1,6):
    Print(i , end = ' ')

    Output will be 1 2 3 4 5

    I want output to be printed in an array like [1,2,3,4,5]

    Please explain this

  3. Thanks for your response

  4. How can we print 1 to 10 numbers with out using loops

  5. How could you say that list comprehension is faster then loop give me the proper explanation

Leave a Reply

Your email address will not be published. Required fields are marked *