Source code of coin_toss.py
from random import choice
side_names = ('heads', 'tails')
guess = input('Enter your guess (heads/tails): ').lower()
flip_result = choice(side_names)
print('Yes!' if flip_result == guess else 'No...', 'It was', flip_result)
Tips for improvement
- Add the while cycle and handle the 'exit' option
- Enable player to enter just the initial letter(s) of his/her choice
- Show the player/computer score
Download
Source code of Coin Toss (coin_toss.py).