list comprehension is the most popular python comprehension it allows us to create new list of elements that satisfy condition from an iterable an iterable is any python construct that can be looped over like listsstringstuplessets in list comprehensions we use square brackets general syntax of list comprehension is as follows[expression for ele in iterable if cond for ele in iterable if cond for elen in iterablen if condnfollowing is an example of list comprehension for creating list of squares of numbers in range =[ * for in range( , )print(sin the previous examplewe can also use if condition to generate only squares of even numberss=[ * for in range( , if % == result of above comprehension will be[ set comprehensions set comprehensions were added to python in version in set comprehensionswe use the braces rather than square brackets for exampleto create the set of the squares of all numbers between and the following set comprehension can be usedx { ** for in range( )print(xoutputdict comprehensions just like set comprehensionsdict comprehensions were added to python in version below we create mapping of number to its square using dict comprehensionx { : ** for in range( )print( { bv prasanthi dept of cse page