Ask Your Question

Revision history [back]

using list comprehension:

sage: [i for i in [1..10] if i%2==0]
[2, 4, 6, 8, 10]

see more alternatives in the Programming in Python and Sage Thematic Tutorial.