Coder Coder Coder Coder - 8 months ago 94
Python Question

Python 3.4 Dice Rolling Simulator Code Error

So I have my code here for a dice rolling simulator game that I am creating using PyDev in Eclipse Neon Python 3.4. Where you guess a number and a number from 1-6 will randomly generate and if you get the number right, you move on, etc.

guess1 = input("Enter your first guess as to which side the dice will roll on (1-6): ")

import random
dice_side = ['1','2','3','4','5','6']

game = print(random.choice(dice_side))

if guess1 == game:
print("Congrats that's the correct guess!")
print("That's the wrong guess!")

I tested out the code and everytime I put in a number, the console always print "That's the wrong guess!". Even when the number I guess matched the generated number. I can't quite figure out what's wrong with this. I was thinking maybe I should use a while loop instead. However, I wanted to know if I can do it this way and what's wrong with this particular code. I am new to Python so any help is appreciated. Thanks in advance!


print() returns None. If you print game after that line you will see it's value. To fix:

game = random.choice(dice_side)