3 ms·
Your list comprehension example is incorrect: car_is_empty() takes the id string, not number.
by pritambaral 7y ago
Your list comprehension example is incorrect: car_is_empty() takes the id string, not number.
- Noumenon72 7y agoI'm sorry, I actually didn't get what the code was trying to do. Result should have been named "empty_car_ids" to signal. What is this "select" function, why isn't it called filter? I actually don't know how to Google this because the HTML select gets in the way. I'd really do it in two lines, because I want to get the first half right and then the second, and be able to inspect the first half independently of the second while debugging. The pipelines don't let you do that. car_ids = [f"car-#{n}" for n in range (1,6)] empty_car_ids = [id for id in car_ids if car_is_empty(id)]
- valuearb 7y agoIf I were to teach a professional programming class, I’d automatically fail the most concise entries, whether they worked or not.