Python dice roll help
Hello all, I am supposed to create a program in Python that gives the output of the something like this
Welcome to the dice roll simulator.
How many sides does the dice have? 4
How many times would you like to roll the dice? 3
** , 2 dots.
**** , 4 dots.
* , 1 dot.
Total value of all rolls: 7
I have been working on figuring out this code for a while. The only guideline I'm supposed
to follow is using diceRoll = random.randint(1, diceSides) to get the final output. However,
I can't even think of a place to start. could anyone give me some pointers on what to do?
Any help is appreciated
-CJ
Edit: I am also supposed to do this using a while loop
OK, here's a better version, with comments explaining what's going on. Hope this helps ![]()
EDIT: You'll need to implement a way to catch the error thrown up if a user doesn't enter a number for either question, then ask the question again. You could even try and interpret when numbers are entered as words. Currently, int(raw_input("")) throws up an error for anything but a number.
EDIT 2: You didn't say whether you are using Python 2 or Python 3. My code is for Python 2. For Python 3, replace raw_input with input.

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now