diff options
Diffstat (limited to 'Chapter10PracDebugCoinToss.py')
-rw-r--r-- | Chapter10PracDebugCoinToss.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Chapter10PracDebugCoinToss.py b/Chapter10PracDebugCoinToss.py new file mode 100644 index 0000000..0b82cbd --- /dev/null +++ b/Chapter10PracDebugCoinToss.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +# Chapter 10 Practice Debugging Coin Toss + +import random + +guess = '' +while guess not in (int(1), int(0)): #Changed heads and tails to 1 and 0 and made integers + print('Guess the coin toss! Enter 1 for heads or 0 for tails:') #Added 1 and 0 + guess = int(input()) #Turned string into integer + +toss = random.randint(0, 1) # 0 is tails, 1 is heads +if toss == guess: + print('You got it!') +else: + print('Nope! Guess again!') + guess = int(input()) #guess misspelled with three 's' instead of two and made guess integer + if toss == guess: + print('You got it!') + else: + print('Nope. You are really bad at this game.') |