Question
Complete the function rotate_list in the t06_functions.py module. The module t06.py provides simple testing for this function. Given a list values as a parameter and
Complete the function rotate_list in the t06_functions.py module. The module t06.py provides simple testing for this function.
Given a list values as a parameter and an integer rotation n, this function rotates the elements in the list by n places. n may be:
positive: elements are rotated from the front of the list to the rear of the list
negative: elements are rotated from the rear of the list to the front of the list
zero: the list is unchanged
as in this diagram:
Rotated Lists
Some examples from executing t06.py:
rotate_list([1, 2, 3, 4, 5], 5)
[1, 2, 3, 4, 5]
rotate_list([1, 2, 3, 4, 5], 13)
[4, 5, 1, 2, 3]def rotate_list(values, n ): Rotates the elements in values n places: A positive n rotates elements from the front to the rear of values. A negative n rotates elements from the rear to the front of values. Use: rotate_list(values, n ) Parameters: values - list of elements to rotate (list of ) n - number of places to rotate values (int.) Returns: None
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started