Skip to content

Commit

Permalink
Merge pull request #1 from rosalindfdt/master
Browse files Browse the repository at this point in the history
first program in computer battlegames
  • Loading branch information
freakboy3742 committed Dec 31, 2017
2 parents 80e3814 + 554ffc9 commit effc6a9
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
import random
import string

print('ROBOT MISSILE')
print()
print('Type the correct code letter (A-Z) to defuse the missile.')
print('You have 4 chances.')
print()

code = random.choice(string.ascii_lowercase)

guesses = 0
success = False

while not success and guesses < 4:
guess = input('What is your guess? ')
guesses += 1

if guess.lower() == code:
success = True
if guess < code:
print('The code is later than %s in the alphabet' % guess)
if guess > code:
print('The code is earlier than %s in the alphabet' % guess)

if success:
print('TICK... FIZZ... CLICK...'
'\nYou did it!')
else:
print('BOOOOOOOOMMM...'
'\nYou blew it!'
'\nThe correct code was \'%s\'.' % code)

0 comments on commit effc6a9

Please sign in to comment.