13 - Snake and Ladder
13 - Snake and Ladder
Input:
import random
def roll_dice():
# Ask the user to provide a dice value between 1 and 6
while True:
try:
roll = int(input("Enter your dice roll (1-6): "))
if 1 <= roll <= 6:
return roll
else:
print("Please enter a valid dice roll between 1 and 6.")
except ValueError:
print("Invalid input, please enter an integer between 1 and 6.")
def play_game():
position = 1
while position < 100:
print(f"\nYou are currently on square {position}")
dice_roll = roll_dice()
position += dice_roll
if __name__ == "__main__":
print("Welcome to Snakes and Ladders!")
play_game()
Output: