New Year Chaos

  • + 0 comments

    can someone explain what is wrong with this code-

    def minimumBribes(q):
        # Write your code here
        res=0
        for i in range(len(q)):
            if (i+1)<q[i]:
                r=q[i]-(i+1)
                if r>2:
                    print("Too chaotic")
                    return
                res+=r
        print(res)
        return