Hiya guys is there a way to print a parameter within a function?
For example I am trying to print the bet parameter within the function below:
import random money = 100 num = random.randint(1, 10) #Write your game of chance functions here def coin_flip(guess, bet): coin_flip = random.choice(['Heads', 'Tails']) #randomly generates heads or tails choice. if coin_flip == 'Heads': return "Congratulations, you guessed correctly! You have won " + str(bet*2) +"!" else: return "Unfortunately you have lost " + str(bet/2) + " better luck next time" #Call your game of chance functions here print(coin_flip('Tails', 30)) money += bet print("You now have £" + str(bet) + " in your account.")
I am trying to print it within this print command:
print("You now have £" + str(bet) + " in your account.")
However each time I try and do that this error message comes up:
Traceback (most recent call last):
File “script.py”, line 15, in
money += bet
NameError: name ‘bet’ is not defined
Any help would be greatly appreciated.