crhodes
Posted on October 17, 2017
Hello,
This is my first time here on dev.to. I need some help fixing a code.
See I'm learning Python from scratch and created this simple game program using Python that randomly rolls a dice in Visual Studio 2015.
But two problems have risen from my program. The first problem is that the dice doesn't exactly roll randomly. It will give me the random number but the numbers will not change until I close the program and only then do I close the program that it will give me another random set of numbers again.
The second problem I have found is when I run the code, it goes into an endless loop. I'm not sure how I am able to make this loop endless but I don't know how to stop it. If anyone can help me fix my mistakes, I'd really appreciate it.
Please find my code here.
import random
min = 1
max = 6
dice = random.randint(1, 6)
dice2 = random.randint(1, 6)
roll_again = "yes"
while roll_again == "yes" or roll_again == "y":
print "Rolling the dices..."
print "The values are...."
print dice
print dice2
if(dice + dice2 == 6):
print("You rolled a 6! You have been cursed!")
elif(dice + dice2 == 7):
print("You rolled a 7! You have been blessed with money")
else:
print("You don't have any blessings")
roll_again = raw_input("Roll the dices again?")
Thank you in advance.
Posted on October 17, 2017
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.