https://www.codecademy.com/practice/projects/games-of-chance

Hello! I’ve run into an error in this project and I cant seem to figure out of to make it work. I was wondering if any of you could help me. Whenever I run this function, it gives me an error saying that the ‘money’ variable was referenced before assignment. Here is the code I wrote:

import random

money = 100

#Write your game of chance functions here

def coin_flip(guess, bet):

Heads = random.randint(1,1000)

Tails = random.randint(1,1000)

win = “Not Defined”

if Heads > Tails:

win = “Heads”

elif Heads < Tails:

win = “Tails”

if guess == win:

money += bet

msg = “You win $” + str(bet) + “!”

return msg

elif guess != win:

money = money - bet

msg1 = “You lost $” + str(bet) + “! Sorry!”

return msg1

#Call your game of chance functions here

print(coin_flip(“Tails”, 100))

Thanks for all the help! I really appreciate it!