ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  An Introduction to Haskell, Part 1: Why Haskell
Subject:   List comprehension in python
Date:   2007-05-24 05:33:37
From:   Skink
To filter the even number in Python I would have used :


even_list = [i for i in [1,2,3,4,5,6,7,8,9,10] if i % 2 == 0]


or even better :


even_list = [i for i in range(1,11) if i % 2 == 0]


1 to 2 of 2
1 to 2 of 2