Coin flip code ALWAYS returns a loss?

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

import random

money = 100

#Write your game of chance functions here
num = random.randint(0,1)
"Heads" == 0
"Tails" == 1
money = 100
def coin_toss(guess,bet):
  money = 100
  if guess == num:
    money += bet
    return money
  else:
    money -= bet
    return money
print(coin_toss("Tails", 6))

my code always returns 94 (i.e a loss). I have ran the code hundreds of times and not a single win, enough evidence to conclude the code is flawed. Help pls.

then the first step would be to inspect your comparison:

print(guess, num)
if guess == num:

then we can see your compare a string with an integer, which is false.

1 Like
"Heads" == 0
"Tails" == 1

What are you trying to accomplish with this part of the code?
Double check this part and what @stetim94 said.

1 Like