Normal list comprehensions occur this way:
new_list = [f(x) for x in l]
What is the most succinct and readable way to create new list in Python similar to this:
new_list = [f(x) while condition is True]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Keep it simple:
There is no benefit to forcing something into a single expression when it is more clearly written as separate statements.