python check if last element in for loop