Skip to content
← Back to Community
I need help I can't seem to get this working
Profile icon
DevilinRobinson

import random
import time
quit = False
SCoRE = 0
scOre = 0
TotalScore = 0
totalscore = 0
print("Dice Game")
time.sleep(5)
#ask user for name
print("PLAYER1")
Name1 = input("Please enter your name to recieve your verification pin\n")
PIN = random.randint(1000000,9999999)
#display PIN
print(PIN)
time.sleep(15)
#Verification
VER = int(input("Please enter the 7-digit Verification pin\n"))
if VER != PIN:
quit = True
else:
print("Verified")
print("PLAYER2")
Name2 = input("Please enter your name to recieve your verification pin\n")
PIN2 = random.randint(1000000,9999999)
#display PIN
print(PIN2)
time.sleep(15)
#Verification
VER2 = int(input("Please enter the 7-digit Verification pin\n"))
if VER2 != PIN2:
quit = True
else:
print("Verified")
#display menu
time.sleep(1.5)
print("menu")
print("P-PLAY")
print("L-Leaderboard")
print("Q-Quit")
Choice = input("-_-\n")
if Choice in ['P','p','Play','play']:
for i in range (0,4):
print("PLAYER1... it is your turn...")
die1 = random.randint(1,6)
print("first roll=",die1)
die2 = random.randint(1,6)
print("second roll=",die2)
SCoRE = die1 + die2
if (SCoRE % 2) != 0:
SCoRE = SCoRE - 5
TotalScore = TotalScore + SCoRE
print("total dice score= " + str(SCoRE))
print("Score so far... " + str(TotalScore))
print("PLAYER2... it is your turn...")
die3 = random.randint(1,6)
print("first roll=",die3)
die4 = random.randint(1,6)
print("second roll=",die4)
scOre = die3 + die4
if (scOre % 2) != 0:
scOre = scOre - 5
print("total dice score= ",scOre)
print("Score so far... ",totalscore)
time.sleep(5)
if SCoRE > scOre:
print("player 1 wins this round...")
elif SCoRE < scOre:
print("player 2 wins this round")
print("Player1 score = ",TotalScore)
print("Player2 score = ",totalscore)
if TotalScore > totalscore:
print(Name1 , " wins ")
TotalScore = str(TotalScore)
file = open("Leaderboard.txt","w")
file = file.write(Name1)
file = open("Leaderboard.txt","w")
file = file.write(TotalScore)
quit = True
elif TotalScore < totalscore:
print(Name2 , " wins ")
totalscore = str(totalscore)
file = open("Leaderboard.txt","w")
file = file.write(Name2)
file = open("Leaderboard.txt","w")
file = file.write(totalscore)
quit = True
elif TotalScore == totalscore:
print("SUDDEN DEATH")
print("PLAYER1... it is your turn...")
die5 = random.randint(1,6)
print("first roll=",die5)
die6 = random.randint(1,6)
print("second roll=",die6)
SCoRE = die5 + die6
if (SCoRE % 2) != 0:
SCoRE = SCoRE - 5
TotalScore = TotalScore + SCoRE
print("total dice score= ",SCoRE)
print("Final score ",TotalScore)
print("PLAYER2... it is your turn...")
die7 = random.randint(1,6)
print("first roll=",die7)
die8 = random.randint(1,6)
print("second roll=",die8)
scOre = die7 + die8
if (scOre % 2) != 0:
scOre = scOre - 5
print("total dice score= ",scOre)
print("Score so far... ",totalscore)
print("Player1 score = ",TotalScore)
print("Player2 score = ",totalscore)
if TotalScore > totalscore:
print(Name1 , " wins ")
quit = True
elif TotalScore < totalscore:
print(Name2 , " wins ")
quit = True
elif TotalScore == totalscore:
print("This game was a TIE go home!!!!!")
quit = True
if Choice in ['L','l','Leaderboard','LeaderBoard','leaderboard']:
print("leaderboard")
if Choice == 'Q':
quit = True

Voters
Profile icon
DevilinRobinson
Comments
hotnewtop
Profile icon
Vandesm14

Why does it take so long to load each time? What's the point of making it wait 15 seconds to show a "enter your pin" message??

Profile icon
linksafe

Remove the random.randint(1000000, 9999999) thingy because it's a big int, or reduce the number @Vandesm14

Profile icon
linksafe

for example, int(random.choices([*"1234567890"], k=7)) @linksafe

Profile icon
linksafe

and there's time.sleep(5) which sleeps for 5 seconds @linksafe