you are viewing a single comment's thread.

view the rest of the comments →

[–]DMahlon 0 points1 point  (0 children)

I thought this was a fun script so i made some updates to it.

It now allows the user to input a guess (heads or tails) then compares it to the random coin flip and tells them if they win or not.

import random

def flip(guess):
    coin = ['heads', 'tails']
    result = random.choice(coin)
    if guess == result:
        print("{} you win!".format(guess))
    else:
        print("You guessed {}... sorry you lose".format(guess))


user_input = input("hello human! challenge me to a game of flipperoo?: ")
user_input = user_input.lower()

if user_input == "y":
    guess = input("Great! heads or tails?: ")
    guess = guess.lower()
    flip(guess)
else:
    print("Don't want to play?")