Blog available for sell
This blog is available for sale. Please 'contact us' if interested.
Advertise with us
game   5   49528
Text based snake and ladder game in python


I quickly wrote a python program to play text based snake and ladder game in terminal.

Any advance python concept is not used in this code. However it is a fun thing to do for a beginner in order to learn how to use multiple concepts in your program.

Few basic concepts used in this code are:
    - Dictionary
    - List
    - Generating random number
    - Selecting a Random value from a list
    - Adding wait/sleep in program
    - Conditional Statements i.e. IF and ELSE
    - Getting input from user


You can download the code from Github.


What is happening in Game:
    - Display the welcome message
    - Collect the player's names
    - Until one of the player wins do the following:
        - Roll the dice
        - Move the player forward for the value got on dice roll.
        - If player is on snake's head, move down to its tail
        - If player is on ladder's bottom, take it to its top
        - else remain there and let second player roll the dice


Run the game using command python3 snake_ladder.py.

snake and ladder game in python


You can set the value SLEEP_BETWEEN_ACTIONS to 0 if you do not want any delay while playing game.



game   5   49528
5 comments on 'Text Based Snake And Ladder Game In Python'
Login to comment

Siva Kumar Feb. 27, 2019, 9:59 a.m.
How to display the movements while playing the game from one to another using image or grid like an app it shows the game?
Arya Anil Feb. 5, 2020, 11:21 p.m.
how can i draw the dfd of this project
Niketa Sharma Feb. 20, 2020, 12:30 p.m.
Sanke & Ladder game memorises my childhood unforgotten movements. You have shared great information. Thanks for sharing it.
Lakshya Sept. 7, 2020, 2:46 p.m.
may i know the modules you used in it...........
Harsh Editz Oct. 15, 2020, 2:20 a.m.
It's wrong pls help Traceback (most recent call last): File "/data/data/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module> start(fakepyfile,mainpyfile) File "/data/data/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start exec(open(mainpyfile).read(), __main__.__dict__) File "<string>", line 106 return player1_name, player2_name ^IndentationError: unexpected indent[Program finished]
DigitalOcean Referral Badge

© 2024-2025 Python Circle   Contact   Sponsor   Archive   Sitemap