def getValues(myDict):
return list(myDict.items())[0][1] # <-- my code returns only 1 value, I need all values
courses = {'CPS141':60, 'CSS210':30, 'CPS161':20}
print(getValues(courses))
expected output: [60,30,20]
CodePudding user response:
You could use a list comprehension:
[value for key, value in myDict.items()]