0

I am new to python, My first project that I am still working on is a kind of a game in which you throw a dice and stuff like that, so it's pretty much a dice simulator.

Before the user actually starts the game I have made the program ask them questions like; "Type 'start' on keyboard to begin the game, and this I am doing with raw_input.

Here's the problem:- I want to make only the input 'start' possible to write, if something else is written, the game doesn't start. I hope you understand me

from random import randint

min = 0
max = 6

start=raw_input("Welcome to the dice game, type 'start' on your keyboard to start the game:")
print("------------------------------------------------------------------------------------------")
name=raw_input("Okey, let's go! Before we can start you must type your name here: ")

print ("Hey %s, I guess we're ready to play!!" % name);
print("The whole game concept is basically to throw a dice and get as high number as possible!")
print("--------------------------------------------------------------------------------------------")
ja=raw_input("Would you like to throw the dice? Type 'yes' if so:")
print "Your number is:", randint(min, max)
print ("Thank you for playing!")
2

1 Answer 1

1

You just need if_else

from random import randint

min = 0
max = 6

start=raw_input("Welcome to the dice game, type 'start' on your keyboard to start the game:")
if start=='start':

    print("------------------------------------------------------------------------------------------")
    name=raw_input("Okey, let's go! Before we can start you must type your name here: ")

    print ("Hey %s, I guess we're ready to play!!" % name)
    print("The whole game concept is basically to throw a dice and get as high number as possible!")
    print("--------------------------------------------------------------------------------------------")
    ja=raw_input("Would you like to throw the dice? Type 'yes' if so:")
    print "Your number is:", randint(min, max)
    print ("Thank you for playing!")
else:
    print("XYZ message")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.