Please help me with the complexity of my code (Rotate the array by k elements question)

Hi, can someone please help me with the time and space ccomplexity of my code? The question is to rotate the array by 'k' elements.
In my answer, for loop is running for k iterations and insert operation takes O(n) time. Does this mean my complexity is O(nk) and this can translate to O(n) if k is small but be O(nn) if k is n (size of the array)?
Also, is my space complexity O(1) considering all operations are in-place?
Please help me with this. I struggle with finding the complexity

if k > len(nums):
        k %= len(nums)
    i = 0 
    n = len(nums)-1
    while i < k:
        element = nums.pop()
        nums.insert(0,element)
        i+=1
Comments (0)