logo codesdope

this is giving me 'None' as output instead of the reverse list of sorted(score)

   Mudit Gupta , IIT Kanpur


score = {40:"x",30:"y",50:"z",45:"a"}
print(sorted(score).reverse())


Answers

  •    gs1

    it is because reverse() doesnt return the reversed list , it modifies the existing list,try this instead

    score = {40:"x",30:"y",50:"z",45:"a"}

    sorted_score= sorted(score)
    sorted_score.reverse()

    print(sorted_score)



Write your answer
Close

Welcome.please sign up.

Close

Welcome.please login.