-
-
Save codecademydev/1524ab5a6cb6c22de5d98038fc4a2e90 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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