Skip to content

Instantly share code, notes, and snippets.

@wkta
Created March 5, 2014 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wkta/9377519 to your computer and use it in GitHub Desktop.
Save wkta/9377519 to your computer and use it in GitHub Desktop.
#MonthOfCode day 4 - error
# imports the sleep function; it will add some suspense
from time import sleep
import random
score = 0
reasonable_player = False
print '*** tough guy simulator ***'
invite_msg = 'so you want to play the russian roulette, hu?'
while(not reasonable_player):
# this inner loop aims at validating the answer
valid_answer = False
while(not valid_answer):
print invite_msg,'y/n'
answer = raw_input()
if( not ('y'==answer or 'n'==answer)):
print 'answer y or n, come on!'
continue
valid_answer=True
if('n'==answer):
reasonable_player=True
continue
print 'you press the trigger, slowly...'
sleep( 1) #waits 1sec
# 6-bullets revolver simulation
if( random.choice( range(1,6)) == 1):
print '*BAM*!'
raise Exception('FATAL ERROR!')
print '*CLICK* nothing happens. Jesus.'
score += 1
invite_msg = 'want more thrill, though guy?'
# displays score + comment
comment = (
'Grow some balls, man!' if (score<3) else (
'Not bad, I respect that!' if (score<5) else (
'Hail to the king! You freak!'
)
)
);
print 'you achieved a score of:',str(score)+'.',comment
@floriancargoet
Copy link

I think a rm -rf is missing somewhere ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment