import random import time def displayIntro(): print('Somehow, you have managed to wake up in a land full of dragons') time.sleep(1) print ('Well done you.') time.sleep(2) print('You are in a bit of a dilemma, in front of you') print('there are 2 caves. In one cave, the dragon is') print('friendly, but in the other, it is quite the') print('opposite. You can not tell which one is which,') print('so it is up to you to choose') def chooseCave(): cave = '' while cave != '1' and cave != '2': print('What cave? (1 or 2)') cave = input() return cave def checkCave(chosenCave): print('You approach the opening of the cave...') time.sleep(3) print('It is very dark and spooky...') time.sleep(3) print('Your heart races as you stand in front of the cave...') time.sleep(2) print('AND A DRAGON JUMPS OUT!!') time.sleep(1) print('HE OPENS HIS JAWS AND...') #7spooky1me print() time.sleep(2) friendlyCave = random.randint(1,2) if chosenCave == str(friendlyCave): print(' GIVES YOU ALL OF HIS TREASURE!!!!') print(':0') else: print('Grabs you, Grills you and eats you with sauteed vegetables.') time.sleep(1) print('What? A dragon cant be a healthy?') playAgain = 'yes' while playAgain == 'yes' or PlayAgain == 'y': displayIntro() caveNumber = chooseCave() checkCave(caveNumber) print('Would you like to try your luck again?') playAgain = input()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question