python


SUBMITTED BY: krasavchek

DATE: Dec. 24, 2015, 6:07 a.m.

FORMAT: Python

SIZE: 427 Bytes

HITS: 1888

  1. import random
  2. guess = ''
  3. while guess not in ('heads', 'tails'):
  4. print('Guess the coin toss! Enter heads or tails:')
  5. guess = input()
  6. toss = random.randint(0, 1) # 0 is tails, 1 is heads
  7. if toss == guess:
  8. print('You got it!')
  9. else:
  10. print('Nope! Guess again!')
  11. guesss = input()
  12. if toss == guess:
  13. print('You got it!')
  14. else:
  15. print('Nope. You are really bad at this game.')

comments powered by Disqus