Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8927433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:13:21+00:00 2026-06-15T08:13:21+00:00

At the very beginning of the Python Script, I have defined a lot of

  • 0

At the very beginning of the Python Script, I have defined a lot of variables. For instance:

cmd_attack = "attack"
cmd_protect = "protect"
cmd_help = "help"

cmd_help works in a user menu function shown here:

def usermenu():
    um_in=raw_input('Menu :: ')
    #Help Command
    if um_in.lower()==cmd_help.lower():
        print(helplist)
        usermenu()

That is successful – it prints the help list and then returns to the raw input. However, when I do something similar involving cmd_help in another function…

def tf_elf_battle_merc():
    battleinput==raw_input('Elf :: ')
    global cmd_help
    global cmd_attack
    global cmd_protect
    if battleinput.lower()==cmd_attack.lower():
        attack_merc()
    elif battleinput.lower()==cmd_help.lower():
        print(tf_elf_help)

That does nothing, prints no errors, and returns to the shell line – without printing anything or going anywhere. I used global commands because I was testing out possible solutions to the problem.
The order that these are put in is the CMD functions at the top, the tf_elf_battle_merc() in the middle, and the usermenu() last. I have tried a few things and the related questions haven’t helped… any thoughts? I’m kind of new to Python. If you’re curious, it is script where you can log in and play text-type games.

The full script is here on Pastebin.

Thank you in advance!

Edit: If you download and run the script – use “Guest” (case-sensitive) as a username and you’ll be let into it

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:13:21+00:00Added an answer on June 15, 2026 at 8:13 am

    Your code (with some edits, seen below) worked fine for me after changing battleinput==raw_input('Elf :: ') to battleinput=raw_input('Elf ::'), you don’t want to compare them, you want to define battleinput.

    However, it should raise an error of that, since battleinput is not defined, yet you’re trying to comparing it: if battleinput.lower() == ....

    Also you’re mixing Python 3 and Python 2? Using raw_input() from Python 2, yet print("asd") from Python 3, instead of Python 2’s print "asd"?

    Everything looks like your code is never reached, the problem is elsewhere.


    Here’s the code for Python 3, which works fine:

    cmd_attack = "attack"
    cmd_protect = "protect"
    cmd_help = "help"
    
    
    def tf_elf_battle_merc():
        battleinput=input('Elf :: ') # Use raw_input() for Python 2
        # You don't need the globals here
        if battleinput.lower()==cmd_attack.lower():
            print("attack")
        elif battleinput.lower()==cmd_help.lower():
            print("help")
    
    tf_elf_battle_merc()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im currently learning python (in the very begining), so I still have some doubts
I am at a very beginning stage of Scala Learning (I have little understanding
I am just beginning my journey into web development and I have a very
I have a very beginning C# question. Suppose I have a class called GameObject
So, in the very beginning, before the send_sms.php is loaded, I have this Json
We have an Open Source software project in the very beginning. The program is
I have just started developing using Youtube API and stuck in very beginning. I
Here's the scenario: I have a Python script that is called from a browser
I have a custom action that runs in the very beginning of my Install
I was looking at Kristina's book and at the very beginning of the intro

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.