Python Forum
function scroll shift
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
function scroll shift
#1
Write a function that takes two arguments — a list ? and a number
? and returns a list of ? elements, scrolled ? elements to the right (elements,
those at the end of the list are placed at the beginning). If ? < 0, the shift must be to the left.

(For example)
In [1]: lrot([1,3,4,2,7,5], 2)
Out[1]: [7,5,1,3,4,2]
In [2]: lrot([1,3,4,2,7,5], -2)
Out[2]: [4,2,7,5,1,3]
In [3]: lrot([1,3,4,2,7,5], 7)
Out[3]: [5,1,3,4,2,7]
In [4]:

I will really greatful for any help!

(Sep-28-2020, 01:18 AM)VenD Wrote: Write a function that takes two arguments — a list ? and a number
? and returns a list of ? elements, scrolled ? elements to the right (elements,
those at the end of the list are placed at the beginning). If ? < 0, the shift must be to the left.

(For example)
In [1]: lrot([1,3,4,2,7,5], 2)
Out[1]: [7,5,1,3,4,2]
In [2]: lrot([1,3,4,2,7,5], -2)
Out[2]: [4,2,7,5,1,3]
In [3]: lrot([1,3,4,2,7,5], 7)
Out[3]: [5,1,3,4,2,7]
In [4]:

I will really greatful for any help!
Reply
#2
Please show your code so far.
We will be glad to help with problems as you encounter them, but will not write the code for you.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020