Hi I dont really sure what I did wrong but it no working. I am making Snakes and Ladders game with out using list

import random

separator = '-' * 20
spaces = [None] * 90
c_l_spaces = {r'slid down a chute ': [[14, 3], [20, 15], [39, 33],[66, 53],[69, 58], [79, 67], [84, 71], [88,36]],'climbed up a ladder |=|': [[6, 17],[24, 26], [30, 44],[49, 62], [82, 86]]}

class Player:

    def __init__(self, number):
        self.number = number
        self.space = 0

    def move(self, roll):
        global spaces
        if (self.space + roll) > 90:
            return (1, 'Your roll would move you off the game board.You remain at space {0}.'.format(self.space))
        elif (self.space + roll) == 90:
            return (0, 'You moved to the last space. You won the game!')
        else:
            self.space += roll
            try:
                space_type = spaces[self.space - 1][0]
                self.space = spaces[self.space - 1][1]
            except TypeError:
                return (1, 'You moved to space {0}.'.format(self.space))
            else:
                return (1, 'You {0} to space {1}!'.format(space_type,self.space))

def roll_die():
    roll = random.randint(1, 6)
    print('You rolled {0}.'.format(roll))
    return roll

def populate_game_board():
    global spaces
    for key, values in c_l_spaces.items():
        for space in values:
            spaces[space[0] - 1] = [key, space[1]]

def initialize_players():
    while True:
        try:
            num_players = int(input('Enter the number of players (0 to exit): '))
        except ValueError:
            print('You have entered an invalid response.n')
        else:
            if num_players == 0:
                print('You have quit the game.')
                return
            elif 1 <= num_players <= 4:
                break
            elif (num_players < 0) or (num_players > 4):
                print('You have entered an invalid number of players.n')

    players = []
    for num in range(num_players):
        players.append(Player(num + 1))

    return players

def start_game(players):
    game = 1
    while game:
        for player in players:
            print('n***Player {0}***'.format(player.number))
            print('You are currently on space {0}.'.format(player.space))
            game_update = player.move(roll_die())
            print(game_update[1])
            print(separator, end='')
            if game_update[0] == 0:
                game = 0
                break
        if game:
            input('nPress Enter for the next turn.')

def initialize_game():
    global game_information
    print(game_information)
    players = initialize_players()
    if players:
        populate_game_board()
        start_game(players)

if __name__ == '__main__':
    initialize_game()

You are trying to print value with no set value line 78, and that variable is never used so just remove lines 77 and 78. You have n instead of \n all around your code and you are using lists as values in c_l_spaces, even you said you can not use them.

yep I notice that I dont really know if I not use values but anyway still get error

print(separator, end='')
^
SyntaxError: invalid syntax

Sorry actually know why because I didnt use python 3.xx I use 2.xx so I delet , end= ' ' outBut when I run still get error

Enter the number of players (0 to exit): 2

***Player 1***
You are currently on space 0.
You rolled 2.
You moved to space 2.
--------------------

***Player 2***
You are currently on space 0.
You rolled 6.
You climbed up a ladder |=| to space 17!
--------------------
Press Enter for the next turn.
Traceback (most recent call last):
  File "Lab4.py", line 83, in <module>
    initialize_game()
  File "Lab4.py", line 80, in initialize_game
    start_game(players)
  File "Lab4.py", line 74, in start_game
    input('Press Enter for the next turn.')
  File "<string>", line 0

    ^
    SyntaxError: unexpected EOF while parsing

input -> raw_input

But is this really your code?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.