Question:
If I want to prompt a player to input their “bet” and/or “wage” in the code below, how would I do that. My code works, except when I attempt to gain input from user. Please see line beginning “val =”.
Exercise link:
https://www.codecademy.com/practice/projects/games-of-chance
Thanks
import random
money = 100
num = random.randint(1, 2)
#Write your game of chance functions here
def coin_flip(bet, wage):
num = random.randint(1, 2)
if bet == "Heads" and num == 1:
balance = money + wage
val = input(f"What is your {bet} and {wage}:")
print(val)
print(f"You won ${wage}!) ")
print(f"You went from ${money} to ${balance}")
if bet == "Tails" and num == 2:
balance = money + winloss
print(f"You bet ${wage}")
print(f"You won ${wage}! ")
print(f"You went from ${money} to ${balance}")
else:
balance = money - wage
print(f"You bet ${wage}, but you lost.")
print(f"Pay out ${wage}.")
print(f"You went from ${money} to ${balance}")
coin_flip("Heads", 15)
coin_flip("Tails", 22)
coin_flip("Heads", 45)