0
#makes a varible called name to identify the players name
name=input("Hello person, Whats your name?")
#prints their name
print("Hello", name)
#console asks the player if they want to play the game, if choice is "yes" then continue,   else say "ok bye bye" (at the bottom!!)
print("Do you want to hear a story?", name)
choice=input("Yes, No?")
if choice==("yes" or "yes " or "Yes" or "Yes "):
    print("Ok", name,", listen up")    
    print("There was once an old, old house at the top of a hill Sooooo high it was above the clouds")
    housename=input("What do you want to call the house?")
    print("The old,",housename,"was once owned by an old lady. You decide to go up to   the", housename, ",you encounter a ghost in your path. You see a varitety of weapons beside  you, an axe, sword and a bow.")
#asks the player if they want an axe sword or bow    
    choice3=input("Do you choose the axe, sword or bow?")
#if the choice is "bow" then proceed with this code    
    if choice3==("bow" or "Bow" or "bow " or "Bow "):
        print("You equip the shoddy Bow, The bow feels as if it could snap any second.")
#sets the enemyshealth as 10
        enemyhealth=int(10)
#makes a while loop to keep the battle going instead of 1 time.
        while enemyhealth >= 1:
            print("Take a shot!")
            bowattack=input("Type attack to fire an arrow!")
            if bowattack==("attack"):
                import random
#randomiser for damage generator
                damage = ["1", "2", "3", "4"]
                damage2 = int(random.choice(damage))
                enemyhealth = enemyhealth - damage2
                print("The ghost took some damage. Enemys health:", enemyhealth)

            else:
                print("Are you sure you typed shoot?")
#if the enemys health gets below 1 print you killed the ghost, reward system! **this is what im having trouble with!!**
    if enemyhealth <= 1:
        print("You killed the Ghost!!")
        print("You vanquished the ghost, you now collect a new weapon!")
#confirms the reward, either gives the player a shiny bow or a double shot bow.
        import random
        reward = ["Shiny bow", "Doubleshot bow"]
#randomiser for either reward
        reward2 =(random.choice(reward)
#prints what weapon the player got
#THIS IS THE PROBLEM, ON THIS LINE
        print("You got a:", reward2)



    #pointless easteregg :D        
    elif choice==("maybe"):
        print("You found an easter egg, congrats. PS this does nothing")
#if the player typed anything other than yes say ok bye bye.
else:
    print("Ok, bye bye", name)

I am fully aware that the code does not yet have the other 2 if statements for the axe or sword. What i'm having trouble with is the reward generator for killing the ghost. I think its an indention error; it says syntax error for the print line.

I know this is rather alot of code to take in but i'd really appreciate it if could help me fix this; if you see anything I could make a shortcut around that would also be helpful. Im using python 3.4.2!

1
  • The same kind of question over and over again. Maybe we should install a bot which detects "syntax error" in the title and answers with "You're missing a closing parenthesis in the previous line." :-) Commented Nov 13, 2014 at 20:33

2 Answers 2

4

You're missing a closing parenthesis in the previous line:

reward2 =(random.choice(reward)

should be:

reward2 =(random.choice(reward))
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, what line is it your talking about. Im pretty much a complete noob to python :(
1

Also, the line if choice==('yes' or 'yes ' or 'Yes' or 'Yes '): wont work.

Try this:

if choice.strip().lower() == 'yes':
    # whatever

strip will remove whitespaces. lower will put the string in lowercase

The same happens with choice3

1 Comment

You welcome... another thing, you don't need to import random anytime you need to call a random function. Import it at the top of your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.