Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #BUGS
- # unable to input non-lower case guesses DONE
- # endless loop if 'heads' or 'tails' not entered DONE
- import random
- import logging
- logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s')
- logging.debug('Start of program')
- guess = ''
- while guess.lower() not in ('heads', 'tails'):
- print('Guess the coin toss! Enter heads or tails:')
- guess = input()
- if guess.lower() not in ('tails', 'heads'):
- raise Exception('You must guess "heads" or "tails".')
- logging.debug('The user\'s guess is: ' + guess)
- toss = random.randint(0, 1) # 0 is tails, 1 is heads
- logging.debug('The toss is: ' + str(toss))
- if toss == guess.lower():
- print('You got it!')
- else:
- print('Nope! Guess again!')
- guesss = input()
- if guess.lower() not in ('tails', 'heads'):
- raise Exception('You must guess "heads" or "tails".')
- logging.debug('The user\'s guess is: ' + guess)
- if toss == guess.lower():
- print('You got it!')
- else:
- print('Nope. You are really bad at this game.')
- logging.debug('End of program')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement