Hey I’m doing the carlys clippers and confused with the last line that asks us to
Carly thinks she can bring in more customers by advertising all of the haircuts she has that are under 30
dollars.
Use a list comprehension to create a list called cuts_under_30
that has the entry hairstyles[i]
for each i
for which new_prices[i]
is less than 30
.
You can use range()
in your list comprehension to make i
go from 0
to len(new_prices) - 1
.
I’m wondering about cuts_under_30 = [hairstyles[i] for i in range(len(hairstyles)) if new_prices[i] < 30] where it has to be range(len(hairstles)) when i print range(len(hairstyles it says range 0, 8 isn’t this already implied? when I try to run the code without the range len it gets TypeError: list indices must be integers or slices, not str maybe i feel there’s jsut an easy way to do it.