python for loop if list not empty