python single line for loop with if else