I'm working on a blackjack game. I put some functions on a different file to help clean up the main file. I put the function that counts the hand value in a separate file in a different function. When I call the variable in the second file, the values change as usual. However, when I call it in the main file, it stays as if nothing happened.
Here's an example:
main.py
import hand
number = ["Ace", "Two", "Three"]
hand = "One"
player_handValue = 0
if playerChoice = "h":
hand.playerHit(player_handValue)
print("main.py: " + player_handValue)
hand.py
def playerHit(player_handValue):
if hand == "Two":
player_handValue += 2
print("hand.py: " + str(player_handValue))
This is kind of choppy since it's not the exact thing I wrote but I think it gets the main idea.
Here's the outcome:
hand.py: 2
main.py: 0
As you can see, the 1 from hand.playerHit
didn't transfer back to main.py's player_handValue
. If anyone could help find a way to fix this, or work around it, please let me know.
What I want:
hand.py: 2
main.py: 2