+ 2
Code challenge isn't working - Python
The code challenge "Fancy Houses" in "Python Data Structures" isn't working for me, can somebody help pls? https://www.sololearn.com/learning/1159/4736/12157/1
4 Answers
+ 1
First, you find the average price in the price list, and then you iterate through the price list to count the number of prices that is bigger than the average price.
+ 2
Can you share your solution as a Sololearn Code? Sololearn's Code Playground has a Python version. You can publish your code there.
I'm pretty strong with Python and want to help but Fancy House is a Pro-only question so I'd like to help without activating Pro on my account.
I see the question says "Calculate and output the number of houses that have a price that is above the average." If there is more detail on the question, can you share that too? You could add it as a multi-line comment using triple-quotes in Python.
+ 1
prices = [125000, 78000, 110000, 65000, 300000, 250000, 210000, 150000, 165000, 140000, 125000, 85000, 90000, 128000, 230000, 225000, 100000, 300000]
#your code goes here
average_price = sum(prices) // len(prices)
prices_above = [i for i in prices if i > average_price]
print( len( prices_above ) )
0
Oh okay, i didn't understand the question correctly. I though u had to print only the average house price, thx Quantum Josh Greig đŹđŹđđđ»đđ»đđ»