Comprehending Comprehensions


#1



what's the difference between the following :

a )

threes_and_fives = [x for x in range(1,16) if x%5==0 or x%3==0]

b)

threes_and_fives = [x for x in range(1,16)
print filter(lambda x: x%3 == 0 or x%5 == 0,threes_and_fives)    


My solution was B .. but the interpreter said it was wrong so I went back to A..


#2

Example 'a' is a list comprehension. I don't know what example 'b' is. The difference could be thus?


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.