how to use next function in python