Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Extracting part off an element in a list python

Im trying to extract only the string part of an element in my list put i can only figure out how to append the int.

this is my list:

{"Java": 10, "Ruby": 80, "Python": 65}

i want the output to be the languages with a grade higher than 60.
in that case

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

"Ruby", "Python"

this is my code but with the append function i can only extract the grade.

def my_languages(results):
    output = [] 

    for i in results:
        if results[i] >= 60:
            output.append(results[i])
    return output

Thank you all in advance

>Solution :

When we traverse the dictionary, the key of the dictionary is index, that is, I, so you need append to be “i”.

def my_languages(results):
    output = [] 
    for i in results:
        if results[i] >= 60:
            output.append(i)
    return output
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading