First time here? Check out the FAQ!
answered 2017-09-17 21:16:13 +0200
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.