Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- def ht_game():
- # user chooses h/t
- choice = input("heads or tails")
- #flip a coin
- coin = coin_flip()
- #announce win/loss
- if choice == coin:
- print("You won")
- else:
- print("You lost")
- def coin_flip():
- flip = random.randint(1,2)
- if flip == 1:
- flip = "heads"
- else:
- flip = "tails"
- return flip
- ht_game()
Advertisement
Add Comment
Please, Sign In to add comment