python one liner for loop with if else