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

  • SEARCH
  • Home
  • 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 7639237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:22:05+00:00 2026-05-31T08:22:05+00:00

I setup a class and it accepts and prints out the variables fine in

  • 0

I setup a class and it accepts and prints out the variables fine in one if statement.

class npc: #class for creating mooks
    def __init__(self, name):
        self.name = name
    def npc_iq (self,iq):
        self.iq = []
    def npc_pp (self,pp):
        self.pp = []
    def npc_melee (self, melee):
        self.melee = []
    def npc_ct (self, ct):
        self.ct = []

It works fine in this if statement

if menu_option == 1:
    print "Choose melees for npc"
    init_bonus = random.randint(0,2)
    char_PP = random.randint(7,15)
    char_iq = random.randint(7,15)
    npc_Melees = int(raw_input(prompt))
    combat_time = math.floor((round_attacks - init_bonus - math.floor(char_PP/2) - math.floor(char_iq/2)) / npc_Melees)
    #function for calculating sequence number
    print "combat time is"
    print combat_time
    mook = "mook%s" % counter # adds different mook names to program
    mook = npc(mook) 
    mook.iq = (char_iq)
    mook.pp = (char_PP)
    mook.melee = (npc_Melees)
    mook.ct = (combat_time)
    counter += 1

But on this statement it will print out the name in the class but not ct.

elif menu_option ==4:
    print "Printing out all mooks"
    print
    printcount = counter -1
    while printcount != 0:
        mookprint = "mook%s" % printcount
        mookprint = npc(mookprint)
        print mookprint.name
        print mookprint.ct 
        print
        printcount -= 1
  • 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-05-31T08:22:07+00:00Added an answer on May 31, 2026 at 8:22 am

    i dont really understand your problem.

    your working example:

    mook = npc(mook) 
    mook.iq = (char_iq)
    mook.pp = (char_PP)
    mook.melee = (npc_Melees)
    mook.ct = (combat_time)
    

    mook.ct is value of (combat_time)

    your failing example:

    mookprint = npc(mookprint)
    print mookprint.name
    print mookprint.ct 
    

    mookprint.ct’s value is nothing because it is never set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a unittest.TestCase that looks like.. class test_appletrailer(unittest.TestCase): def setup(self): self.all_trailers =
I have something like this set up: class CategoryPage (webapp.RequestHandler): def get(self): ** DO
Given an hypothetical utility class that is used only in program setup: class MyUtils
i have the following models setup class Player(models.Model): #slug = models.slugField(max_length=200) Player_Name = models.CharField(max_length=100)
How do I setup a class that represents an interface? Is this just an
If I have a simple class setup like this: class MyClass { private string
I setup custom CSS class for array of dynamic TextBoxes (inputs as HTML) so...
I've setup an own class(custom UIView). I'am adding two of these customViews to my
I have a page that is setup like this public partial class _Default :
For my tests I'm using a base class MyTestBase defining a method setup() that

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.