I'm writing a program that simulates a game of Bunko for my compSci class, but I'm having issues getting the function scoreCalc
to modify the global variable playerScore
. The game pits a player against the computer, so I wanted to be able to use one function to determine the score and just pass an in argument to increment the correct score respectively. However, the function is not saving the value of playerScore
across multiple plays, resetting to 0 with each round. I'm new to functions, so I'm sure the issue is likely something trivial, but I appreciate any and all help!
dieList = []
sixCount = 0
playerScore = 0
def rollDice():
global sixCount
sixCount = 0
dieList.clear()
die1 = random.randint(1,6)
die2 = random.randint(1,6)
die3 = random.randint(1,6)
dieList.append(die1)
dieList.append(die2)
dieList.append(die3)
print(dieList)
for x in dieList:
if x == 6:
sixCount += 1
print("sixCount:", sixCount)
return
def scoreCalc(x):
if sixCount == 1:
x += 1
elif sixCount == 2:
x += 5
elif sixCount == 3:
x += 21
return x
print()
print("Player's turn!")
print('*' * 30)
input("Press ENTER to roll the dice")
print()
rollDice()
print("Score:", scoreCalc(playerScore))