Dec-09-2019, 06:36 PM
I have created a super basic text based snakes and ladders game. I felt presetting the positions of the snakes and ladders was the best way to go about it, but it just makes it long and tedious to write. Is there any way to compact or condense it down? Or is there no way around this? Thanks in advance, this will help me a lot on my GCSE course.

def snakes_ladders_positions(): global snake_pos1 global snake_pos2 global snake_pos3 global snake_pos4 global snake_pos5 snake_pos1 = random.randint(10,20) snake_pos2 = random.randint(22,40) snake_pos3 = random.randint(42,60) snake_pos4 = random.randint(62,80) snake_pos5 = random.randint(82,90) global ladder_pos1 global ladder_pos2 global ladder_pos3 global ladder_pos4 global ladder_pos5 ladder_pos1 = random.randint(10,20) ladder_pos2 = random.randint(22,40) ladder_pos3 = random.randint(42,60) ladder_pos4 = random.randint(62,80) ladder_pos5 = random.randint(82,90)