Python | List Comprehension in 2 minutes

Python

Video is ready, Click Here to View ×


This two minute Python scripting tutorial is focused on List comprehension. We can condense an expression, a loop and condition into a single line of code easily using List Comprehension, one of the coolest features of python.

=============================

➤ Full Article

Python | List Comprehension in 2 minutes!

Video is ready, Click Here to View ×

➤ Impatient Programmer:
https://www.ImpatientProgrammer.net

➤ Exercises:

5 thoughts on “Python | List Comprehension in 2 minutes

  1. you missed dict comprehension and set comprehension i.e

    >>> {hex(v): v ** 2 for v in range(10)}
    {'0x0': 0, '0x1': 1, '0x2': 4, '0x3': 9, '0x4': 16, '0x5': 25, '0x6': 36, '0x7': 49, '0x8': 64, '0x9': 81}

    >>> {i for i in [1, 1, 2, 3, 2, 4, 5, 7, 6, 7]}
    {1, 2, 3, 4, 5, 6, 7}

Leave a Reply

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