for loop with if else in python single line