Protect Python 3 from changing dict in loop