if (year = and year ! or (year = )leaps append(yearwhen the built-in range(function is given two integer argumentsn and mthe iterator it returns produces the integers nn of courseif we knew the exact range beforehand we could use list literalfor exampleleaps [ list comprehension is an expression and loop with an optional condition enclosed in brackets where the loop is used to generate items for the listand where the condition can filter out unwanted items the simplest form of list comprehension is this[item for item in iterablethis will return list of every item in the iterableand is semantically no different from list(iterabletwo things that make list comprehensions more interesting and powerful are that we can use expressionsand we can attach condition--this takes us to the two general syntaxes for list comprehensions[expression for item in iterable[expression for item in iterable if conditionthe second syntax is equivalent totemp [for item in iterableif conditiontemp append(expressionnormallythe expression will either be or involve the item of coursethe list comprehension does not need the temp variable needed by the for in loop version now we can rewrite the code to generate the leaps list using list comprehension we will develop the code in three stages first we will generate list that has all the years in the given rangeleaps [ for in range( )this could also be done using leaps list(range( )now we'll add simple condition to get every fourth yearleaps [ for in range( if = finallywe have the complete versionleaps [ for in range( if ( = and ! or ( = )range(