Carlly's Clippers Question

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]
total_price = 0
for price in prices:
total_price = total_price + price
print(total_price)
average_price = total_price/len(prices)
print("Average Haircut Price: " + str(average_price))
new_prices = [price - 5 for price in prices]
print(new_prices)
#Revenue
total_revenue = 0
for i in range(len(hairstyles)):
total_revenue = [prices[i] * last_week[i]]
print("Total Revenue: " + str(total_revenue))

So this is the code that I put in for Step 9: the one where you need to figure up the total revenue for the shop. Now, I made a mistake in the code; it should be “” total_revenue += prices[i] * last_week[i] “”, but what I wrote about is still throwing 70 for total_revenue and I can’t figure out why that is. If anyone has any insight it would be greatly appreciated; loops have been a bit of a struggle so I’d like to get as much info on them as possible. TIA

If you want to use the new prices to compute the revenue, you’d use new_prices instead of prices
So

for i in range(len(hairstyles)):
  total_revenue += new_prices[i] * last_week[i]

instead of

for i in range(len(hairstyles)):
  total_revenue += prices[i] * last_week[i]
1 Like