Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print an entire list while not starting by the first item

Tags:

python

list

I'm trying to figure out how to print the following list while not starting by the first item. To be clear: If the list is [0,1,2,3,4,5,6,7,8], I want to print something like 4,5,6,7,8,0,1,2,3

Here's the code:

you_can_move_on = False

List = [0,1,2,3,4,5,6,7,8]

next_player = 3

while not you_can_move_on:
    next_player = self.get_next_player_index(next_player)
    you_can_move_on = self.check_if_I_can_move_on
    print(next_player)


def get_next_player_index(self, i):
    if i == len(self.players):
        return 0
    else:
        return i+1

def check_if_I_can_move_on(self):
    return False
like image 986
RageAgainstheMachine Avatar asked Dec 15 '15 02:12

RageAgainstheMachine


1 Answers

I think it should be

print(l[3:] + l[:3])
like image 64
GAVD Avatar answered Oct 30 '22 07:10

GAVD