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 7677761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:29:45+00:00 2026-05-31T17:29:45+00:00

I am learning Python, following a book (Python Programming for the Absolute Beginner, 3rd

  • 0

I am learning Python, following a book (Python Programming for the Absolute Beginner, 3rd Edition).
The book gives an example of a basic Sims like application, where a finite number of “critters” are created, and the user must feed and play with them, increasing their boredom and hunger values.
I was practicing using classes, and tried to make my own game. The user was presented with a menu where the user could; buy/create a new sim, delete an old one, or interact with existing ones.
The problem I’m having is with creating new classes. The user is initially presented with a screen asking what they would like to do, and if they press X, they are taken to the createnewsim function. However the problem is when a new class is made:

nameofsim = input("what would you like to call your new sim?")
newsim = sim(nameofsim)

If the user were to make another, it would overwrite the existing one, since the name newsim cannot be changed, as I discovered in a previous question, more or less.

So, how do I allocate new object names, or prevent old sims from being overwritten, allowing for the creations of more than one new sim??

  • 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-31T17:29:46+00:00Added an answer on May 31, 2026 at 5:29 pm

    Either store your sim classes in a list or a dictionary; e.g.

    class Sim(object):
        def __init__(self, name):
            self.name = name
    
    names = ['tim','dave','jane']
    sims = {}
    for name in names:
        sims[name] = Sim(name)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently learning python programming (and am a beginner at it). Currently I
I'm learning how to use sqlite3 with python. The example in the text book
I'm learning Python. I'd like to do the following task: Input: a list: e.g.,
I am learning how to code through this book called Headfirst Programming, which I
I have been learning Python by following some pygame tutorials . Therein I found
I'm learning Python and WxPython . So far, I'm following the examples in AnotherTutorial
I have the following Python (3.2) code: from pygame import * class Application: def
I am learning python and i can't figure out why the following program is
I'm learning Python (with Python 3.2) and have been following a few manuals. In
i am new to python and learning it for my job functions. im following

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.