Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2017
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    This is my first time ever codeing and need help with my first little game thing

    So none of my elif and input functions work this is my first bit of coding and I just can't fix it. Wondering if you guys have any ideas.

    The first part works, but when it gets to options it doesn't work.
    Thank you!


    print("Hey")
    name=input("What's your name?")
    print("Hello, "+ name +"!")
    age=input("How old are you")
    gender=input("And what gender are you")
    weapon=input("What kind of weapon do you want?")
    print("So a "+ weapon +"?")
    print("You have to protect the kingdom "+ name +"!")
    move = input("You come to a path do you go left or right")
    if move == 'left' :
    print("A Giant ogre blocks your path!")
    print("He demands all your money")
    answer = input("Do you give him your money")
    if answer == 'no' :
    print("The ogre picks up his club and slams it into your head")
    print("The last thing you see is the ogre lifting you into his mouth")
    print("Game Over")
    elif answer == 'yes':
    print("The ogre puts his hand out, and you hand him the money")
    print("Seeming very pleased with himself he lets you pass")

    elif move == 'right' :
    print("The road stretches on farther, and farther")
    entrance = input("Will you go into the inn?")
    if entrance == 'yes' :
    print("A small man is sitting behind the counter as you walk in")
    elif entrance == 'no' :
    print("As you continue walking throught woods you hear a small rustling.")
    print("You turn your head to look just as several men jump out of the under brush.")
    print ("They demand to know if you are armed.")

  2. #2
    New Coder
    Join Date
    Jul 2013
    Posts
    16
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I gave your code proper indentation, and it worked fine. In Python, indentation sets off compound statements like loops and branches.

    Code:
    print("Hey")
    name=input("What's your name?")
    print("Hello, "+ name +"!")
    age=input("How old are you")
    gender=input("And what gender are you")
    weapon=input("What kind of weapon do you want?")
    print("So a "+ weapon +"?")
    print("You have to protect the kingdom "+ name +"!")
    move = input("You come to a path do you go left or right")
    if move == 'left' :
        print("A Giant ogre blocks your path!")
        print("He demands all your money")
        answer = input("Do you give him your money")
        if answer == 'no' :
            print("The ogre picks up his club and slams it into your head")
            print("The last thing you see is the ogre lifting you into his mouth")
            print("Game Over")
        elif answer == 'yes':
            print("The ogre puts his hand out, and you hand him the money")
            print("Seeming very pleased with himself he lets you pass")
    elif move == 'right' :
        print("The road stretches on farther, and farther")
        entrance = input("Will you go into the inn?")
        if entrance == 'yes' :
            print("A small man is sitting behind the counter as you walk in")
        elif entrance == 'no' :
            print("As you continue walking throught woods you hear a small rustling.")
            print("You turn your head to look just as several men jump out of the under brush.")
            print ("They demand to know if you are armed.")


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •