#!/usr/local/bin/python2 l = ({1:1}, {2:1}, {3:1}, {4:1}, {5:5}, {6:1}, {7:1}, {8:1}, {9:1}) for i in xrange(500000): for e in l: v = e.get(5) if v is not None: break print v