Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- secret = random.randint(1,100)
- limDn = 1
- limUp = 100
- tries = 6
- print('Arr, I\'m the Dread Pirate Roberts, and I have a secret!\nIt\'s a number from 1 to 100. I\'ll give you 6 tries.')
- guess = input('What\'s yer guess, matey?\n')
- while int(guess) != int(secret) and int(tries) > 0:
- if int(guess) > int(secret):
- print('Too high, landlubber!')
- limUp = guess
- elif int(guess) < int(secret):
- print('Too low, ye scurvy dog!')
- limDn = guess
- tries -= 1
- print('Yer range is', limDn, 'to', limUp)
- guess = input('What\'s yer guess, matey?\n')
- if int(guess) == int(secret):
- print('Avast! Ye got it! Found my secret, ye did! With', tries, 'tries left!')
- else:
- print('No more tries, matey! Better luck next time! The secret number was', secret, end='.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement