• Python question of the day

    What would be the output of executing the following code:
    print(sorted([8,5,9,5,7], key=lambda x:0 if x==9 else x))
     [5, 5, 7, 8]
     [5, 5, 7, 8, 9]
     [9, 5, 5, 7, 8]
     [5, 5, 9, 7, 8]
    Explanation:
    Sorts according to the key function in ascending order unless the element is 9


    Top 100 python interview questions:


  • python bootcamp 2021
datai analytics