combine for loop and if statement python