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
"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