I have no idea


Hello I don't know were else to post this I did not want to start a new account on a different websites to ask just one question. I've been learning Python 3 and I just cant figure out why this program wont run. I've gone through it with the debugger but I get nothing. It would be really cool to find out what I did wrong with my code cause I want to learn.

import random
import time

def display():
print('You are in a land of dragons and in front of you is ')
print('two caves one cave has a dragon that will share ')
print('two caves one cave has a dragon that will share ')
print('the knowledge of lifting in the other is a dragon that will kill you on sight')

def chooseCave():
cave = ' '
while cave != '1' and cave != '2':
print('Brave traveler which cave do you choose? 1 or 2?')
cave = input()
return cave

def checkCave(chooseCave):
print('You approach teh cave...')
print('It is dark and spooky')
print('The dragon jumps out in front of you and opens his mouth and...')


if chooseCave == str(friendlyCave):
    print('Gives you the secret to fitness...Its rely not that cool go read a book')
    print('He eats you up from the foot to your head...Man that sucks!')

playAgain = 'Yes'

while playAgain == 'yes' or playAgain =='y':
print('Would you like to play again User? (Yes or No)')
playAgain = input()


You should write 'yes' instead of 'Yes'

playAgain = 'yes'


You check for non-capital-letter yes and that's why it won't start :smiley:


I'm just going to list some things as I see them:

  • your code:
    print('Brave traveler which cave do you choose? 1 or 2?')
    cave = input()

  • try this:
    cave = raw_input("Brave traveler which cave do you choose? 1 or 2?")

  • you defined 'playAgain' without asking the user...

  • I am just going to rewrite a bit of your code and paste it for you to take a look at here:

while True: 
    ''' caveNumber = chooseCave() would not work '''
    caveNumber = cave
    ''' you have to write it like this for it to understand that is needs to handle a yes or no answer '''
    playAgain = raw_input("Would you like to play again? Enter [yes or no]: ")
    if playAgain.lower()[0] == "y":
    elif playAgain.lower()[0] == "n":
        ''' This is to handle if they type something random like "nipples", for example... '''
        print "Invalid input"
        print "Exiting..."

This above code needs to be placed where you wrote this:

Hope I could help! :slightly_smiling:


Thank you it works now. Computers man they can be tricky.


You're welcome ^^
Computers are more dumb than you think, you have to tell them literally everthing :wink:


This post was flagged by the community and is temporarily hidden.