Data Analysis with Python Projects - Demographic Data Analyzer

My code passes the test when I run it outside of replit, but not there. The code thats giving me issues is this part:

countries=df["native-country"].value_counts().index.tolist()
ptmp=0
ctmp=""

for country in countries:
    try:
        percent=df[["native-country","salary"]].value_counts()[country][">50K"]/df[df["native-country"]==country].shape[0]*100
    except:
        percent=0.0
    
    if percent>ptmp:
        ctmp=country
        ptmp=percent

highest_earning_country = ctmp
highest_earning_country_percentage = float("%.1f" % ptmp)

It says the answer is incorrect because highest_earning_country=“” and highest_earning_country_percentage=0.0. In VSCode it does fill properly giving the answers it should.

Why would this happen?

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36

Challenge: Data Analysis with Python Projects - Demographic Data Analyzer

Link to the challenge:

Please post the link to the repl, so that it is available for debugging.

my code is working fine outside of replit but not on the replit. Below is a link to my work. Thank you
boilerplate-demographic-data-analyzer (3) - Replit hi

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