Python List Comprehension Carly's Clippers Challenge

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

Hello Python community I have a quick question. I am having trouble with Python List Comprehsnion in particular with Carly’s Clippers. I see the get unstuck video and it is most helpful however I am having trouble figuring out what to write for each loop. The cheatsheet shows a general example of list comprehension but I really need the syntax explained to me. I see the hints tabs and I open them and it gives me the answer but I will not have the hint tab with me when I am on the job.

My question is this,

what are the right questions to ask when trying to do list comprehension? How do I know what to put for each loop?

link to exercise:

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

First, the documentation might demystify a bit:

From the docs:
" A list comprehension consists of brackets containing an expression followed by a for clause, then zero or more for or if clauses. The result will be a new list resulting from evaluating the expression in the context of the for and if clauses which follow it."

Are you referring to step 5?

new_prices = [price - 5 for price in prices]