use built-in next function, compatible with python 2 and 3