Pythons Games of Chance

Hi all :slight_smile:

Im currently working on the games of chance project, and ive finished my code up to a certain extent, but id like for a user input prompt to appear instead of having to type the game functions in the code itself and defining whether or not its heads or tails, however when it prompts the user for input, and how much they would like to bet, nothing happens and the process finishes, im assuming its because it is not linked together somehow but im unsure on how to do that?

import random


money = 100

#Functions for the actual game are here
def coin_flip(guess, bet):
  side = random.randint(1, 2)
  if guess == "Heads" and side == 1:
        total_money = money + bet
        print(int(bet))
        print("Heads, you won! Your total money is now " + str(money + bet))
        return total_money
  if guess == "Tails" and side == 2:

        total_money = money + bet
        print(int(bet))
        print("Tails, you won! Your total money is now " + str(money + bet))
        return total_money
  else:
      total_money = money - bet
      print(int(-bet))
      print(("You lost! Your total is now ") + str(money - bet) + ".")
      return total_money


# Game functions are called here
coin_flip = input("What side of the coin would you like to guess? ")
type(coin_flip)
bet = input("How much would you like to bet? ")
type(coin_flip)

Well I don’t see how you are passing the inputs into the function.
I haven’t done python yet but I have experience in javascript.

Seems to me you need something like this:

side = input("What side of the coin would you like to guess? ")
amount = input("How much would you like to bet? ")

And then invoke the function coin_flip

coin_flip(side, amount)

Hello, @course5641557636.

In the Codecademy learning environment, you unfortunately can’t get user input in this project. If you are doing it offsite, as @janneslohmeijer said, you’ll need to invoke your function with the arguments you’ve retrieved from the user. You will run into an issue with your current code. You have a function named coin_flip, but you’ve re-used that name for a user input value, so what will happen when you try to invoke coin_flip(coin_flip, bet)?