Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple code help needed
#3
Here, I'll just post the whole code so you can see. I don't really understand much but I just wanted tot try doing something
axe = False
sword = False
health = 100
def begin():
    print("Game starting!\n\n")
    q1()

def q2a():
    q2a=input("You walk to the chest. You find that the chest is empty, but the skeleton has a sword and an axe but you can only hold one.\nDo you want to take the sword(1)?, or the axe(2)")
    if q2a == "1":
        sword = True
        print("Sword was taken")
        q2b()

    if q2a == "2":
        axe = True
        print("Axe was taken")
        q2b()
        
def q2b():
    q2b=input("You are attacked by a wolf that jumps out of the trees nearby!\nDo you want to fight(1)?, or run(2)?")
    print(sword)
    print(axe)
    if q2b == "1":
        
        if sword == True:
            print("You slash off the wolves head before it attacks you, killing it.")
            print("You have,",health,"remaining")
        elif axe == True:
            print("The wolf bites you once and you swing your axe at the wolf, cutting it clean in half.")
            health = health - 20
            print("You have,",health,"remaining")
        else:
            print("Your bare hands were not strong enough, and you were killed. Returning to menu!")
            menu()
    if q2b == "2":
        print("You are chased and killed by the wolf. Returning to menu!")
        menu()

def q1():
    q1=input("You have woken up in the middle of nowhere with nothing but your clothes. You see an open chest with a skeleton nearby.\nDo you want to check out the chest(1) or walk the other way?(2)\n")
    if q1 == "1":
        print("You have",health,"health") 
        q2a()
    if q1 == "2":
        print("You have",health,"health") 
        q2b()


def menu():
    print("""
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓
▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓
▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓Stranded island game▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓
▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓
▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓
▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓
▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓Play?            Y/N▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓
▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓
▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▓
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
""")
    play=input()
    if play == "Y":
        begin()
    elif play == "N":
        print("Bye!")
    else:
        print("Enter a valid choice")
    

menu()
Reply


Messages In This Thread
Simple code help needed - by Harveyyy - Feb-07-2018, 05:21 PM
RE: Simple code help needed - by nilamo - Feb-07-2018, 07:19 PM
RE: Simple code help needed - by Harveyyy - Feb-07-2018, 08:39 PM
RE: Simple code help needed - by nilamo - Feb-07-2018, 09:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple code not working properly tmv 2 666 Feb-28-2025, 09:27 PM
Last Post: deanhystad
  Windows Disk Cleanup Code Help Needed nal2us2 3 1,196 Jul-19-2024, 04:03 AM
Last Post: deanhystad
  Help with simple code JacobSkinner 1 1,486 Mar-18-2024, 08:08 PM
Last Post: deanhystad
  I have a code which is very simple but still I cannot detect what's wrong with it max22 1 1,391 Nov-07-2023, 04:32 PM
Last Post: snippsat
  help me simple code result min and max number abrahimusmaximus 2 1,860 Nov-12-2022, 07:52 AM
Last Post: buran
  Code Assistance needed in saving the file MithunT 0 1,450 Oct-09-2022, 03:50 PM
Last Post: MithunT
  Simple encoding code ebolisa 3 2,501 Jun-18-2022, 10:59 AM
Last Post: deanhystad
  How would you (as an python expert) make this code more efficient/simple coder_sw99 3 2,701 Feb-21-2022, 10:52 AM
Last Post: Gribouillis
  Simple code question about lambda and tuples JasPyt 7 5,054 Oct-04-2021, 05:18 PM
Last Post: snippsat
  My simple code don't works !! Nabi666 1 2,142 Sep-06-2021, 12:10 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020