Carly's Clippers - TypeError with step 8 using code in solution

https://www.codecademy.com/courses/learn-python-3/projects/carlys-clippers

Here’s my code so far for the project. However I keep getting a Type Error for my last line of code. I don’t understand why because it is the same code used by the instructor.
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 += 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)

total_revenue = [0]

for i in range(len(hairstyles)):

total_revenue += prices[i] * last_week[i]

Screen Shot 2021-01-09 at 1.17.38 PM
Here is the code as a screen shot

You can format code for the forums (short chunks at least), see this FAQ for a little detail.

If you have an error then the specific error and the line number in the trace can also be very helpful.

As for potential errors, what would be the difference in the way you calculate total_price and total_revenue?

Screen Shot 2021-01-09 at 1.23.33 PM

I am using the same code as provided by the instructor

Is that all the code that relates to these calculations?

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 += 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)

total_revenue = [0]

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

Screen Shot 2021-01-09 at 1.28.44 PM

Thanks for sorting formatted code and the full details. There’s still a difference in the way total_revenue and total_price are set up. How are these values first defined?

Thanks for the tip!
changed

total_revenue = [0]

to

total_revenue = 0

and it worked!

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.