Advertisement
mengyuxin

meng.guessCoin.py

Jan 3rd, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. #! python3
  2. # guessCoin.py
  3. import random
  4.  
  5. guess = ''
  6. while guess not in ('heads', 'tails'):
  7.     print('Guess the coin toss! Enter heads or tails:')
  8.     guess = input().lower()
  9.  
  10. toss = ('tails', 'heads')[random.randint(0, 1)] # 0 is tails, 1 is heads
  11.  
  12. if toss == guess:
  13.     print('You got it!')
  14. else:
  15.     print('Nope! Guess again!')
  16.     guess = input().lower()
  17.     if toss == guess:
  18.         print('You got it!')
  19.     else:
  20.         print('Nope! You are really bad at this game.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement