• Python question of the day

    What would be the output of executing the following code:
    str1 = 'a quick red fox'
    str1[-2::str1.count('k')]
     fox
     ox
     of
     of der kciuq a
    Explanation:
    In str1[-2::str1.count('k')] start is -2 (-1 is x -2 is o so start is at o) end is default as there no value for end point (default is end of the string, so x here) step size is 1 as there is only one k in the string, so the slice is ox (starting from second element from last and till last in steps of 1)


    Top 100 python interview questions:


  • python bootcamp 2021
datai analytics