Python3 polyfill for list assertion
Don't remove keys while iterating