I was writing a text adventure in python and i ran into a "NameError: name 'military' is not defined" error and i need help, heres the code

this is the part with the prob:

choice = raw_input("Pick your civ:")
            if choice == military:

thnx for your time

--
Tom tetlaw
i rule

Recommended Answers

All 2 Replies

raw_input returns a string, so your test should be

if choice == "military":
    ...

With your code, python thinks that military is a variable's name and complains because there is no such variable.

Thanks tons!
you fixed the problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.