Help, I am stuck at task 8 in the assignment "Carly's Clippers"

I am working on Python 3, Loops section.
I am stuck at task 8 in the assignment “Carly’s Clippers”
The task is: “Use a for loop to create a variable i that goes from 0 to len(hairstyles)”
“Hint: You can use range() to do this!”

I can make a loop but not in combination with range
BTW: the list “hairstyles” has a length of 8
Who can help me
thanks in advance Paul

Can you please post your formatted code?
Use the </> button or see:

More on range():

Hai LisaLisaJ hier is my code
< hairstyles = [“bouffant”, “pixie”, “dreadlocks”, “crew”, “bowl”, “bob”, “mohawk”, “flattop”]

prices = [30, 25, 40, 20, 20, 35, 50, 35]

last_week = [2, 3, 5, 8, 4, 4, 6, 2]
print (“*_*“)
#1
total_price = 0
print (”
*_*”)
#2
for price in prices:
print (price)
total_price = (price + total_price)
print (total_price)
print (“*_*“)
#3
aantal=len(prices)
#print (aantal)
average_price = total_price / aantal
print (”
*_*”)
#4
print (“Average Haircut Price:”, average_price)
print (“*_*“)
#5
new_prices= []
new_prices=(n-5 for n in prices)
print (”
*_*”)
#6
for nprice in new_prices:
print (nprice)
print (“*_*“)
#7
total_revenue = 0
print (”
*_*”)
#8
i = len(hairstyles)
for n in range(i):
print (i)
i =i -1
print (“*_**_”)

The code is till 7 is a bit differtent thand the original bc i did some playing with the code.
Paul

Be sure to remove all those print statements before submitting.

new_prices= []
new_prices=(n-5 for n in prices)

Did you mean,

new_prices = [n - 5 for n in prices]  #  list comprehension

?

Did you mean,

for i in range(len(hairstyles)):
    print (hairstyles[i])

?

1 Like

Hi MTF,
Thanx already.

I will delete all the print statements.
I think i mean :
<
for i in range(len(hairstyles)):
print (hairstyles[i])

I go and try it

1 Like