Tell us what’s happening:
Could any one please help with the code for
highest_earning_country. When I try am getting United states but am not sure how they are getting Iran.
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36.
I’m struggling on this one too. I know how they came up with Iran, I’m just having issues trying to find the right code configuration for it.
The question is really asking which country has the highest percentage of >50K salaries.
You would need to take all the salaries for each country (let’s call this ‘all_salaries’). You then need to find out for each country the count of salaries over 50K (let’s call this ‘over50k’.) Then divide ‘over50k’ by ‘all_salaries’ (eg. ‘over50k’ / ‘all_salaries’), again for each country.
Iran has a total of 43 ‘all_salaries’ and 18 of those are ‘over50k’.
18/43 = 0.418605 or 41.9%
I’m just trying to find out how to isolate those sums and values to get that answer.
I think you found the answer perfectly in your breakdown. Did you try to simply combine the (2?) lines of code you found the 2 numbers with (it might take some tinkering with brackets)? After that it’s just a matter of making it a percentage calculation and rounding to 1 digit (as you did earlier in this exercise).