1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#!/usr/bin/env python

# List comprehension for all years in a given interval
years = [x for x in range(1870,2130)]

# List comprehension containing only leap years
schaltjahre = [x for x in years if ((not x%4) and (x%100)) or (not x%400)]

# Or in one common expression
schaltjahre = [x for x in range(1870,2130) if ((not x%4) and (x%100)) or (not x%400)]

print 'Die folgenden Jahre sind Schaltjahre'
print schaltjahre