Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created February 21, 2020 01:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/1524ab5a6cb6c22de5d98038fc4a2e90 to your computer and use it in GitHub Desktop.
Save codecademydev/1524ab5a6cb6c22de5d98038fc4a2e90 to your computer and use it in GitHub Desktop.
Codecademy export
import random
money = 100
name = print("Hey, welcome to Heads and Tails game!")
#Write your game of chance functions here
def HeadsTails(guess, bet):
flip = random.radint(1, 2)
Tail = 1
Head = 2
guess = input("Tail or Head? ")
bet = input("How much to bet ? ")
if ((flip == 1) and (guess == Tail)) or ((flip == 2) and (guess == Head)) :
money = money + bet
return print("Congratulations, you won! Your balance is $" + money )
else:
money = money - bet
return print("Sorry you lost, try one more time! You have $" + money + " left. ")
HeadsTails(Tail, 11)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment