0

I know python does not have a definite command to move all the items in a array by so many numbers. But I cannot find a way to move the positions one by one.

My desired outcome would preferably simple as I am a python novice :)

Thanks if you can help.

My code is currently only in pseudocode

but heres a example:

PlayerName = ["Helen", "Adam", "Kwaku"]

But I need a line of code to move the numbers. eg:

kwaku, Helen, Adam. so all positions move by 1.

  • 2
    Please provide sample data, i.e. data before operation and desired data after operation – Daweo Jun 14 '21 at 09:30
  • `list.insert`, `list.pop`…? – deceze Jun 14 '21 at 09:32
  • @Daweo I only currently have it in pseudocode, but my desired data would be for the array to move places by a number inputted by a user :) – brynisaweeb Jun 14 '21 at 09:32
  • @deceze Correct me if I'm wrong but I'm pretty sure list.insert wouldn't work as the array is filled and does not need anything adding to it. I just need to shift the elements in the array :) – brynisaweeb Jun 14 '21 at 09:34
  • You can't do that. An array (`list`?) must be contiguously filled, you can't have "non-existing" indices. At most you can `insert` `None` values. – deceze Jun 14 '21 at 09:36
  • You want to *rotate* the list…? – deceze Jun 14 '21 at 09:39

0 Answers0