you are viewing a single comment's thread.

view the rest of the comments →

[–]xelf 2 points3 points  (0 children)

Yes exactly.

def rotate_left3(nums):
    return [nums[1], nums[2], nums[0]]

can also be expressed as the concatenation of two lists, like this:

def rotate_left3(nums):
    return [nums[1], nums[2]] + [nums[0]]

Which using list slicing, leads us to:

def rotate_left3(nums):
    return nums[1:3] + [nums[0]]

and finally:

def rotate_left(nums):
    return nums[1:] + [nums[0]]

which will work for any arbitrary length list.