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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:57:18+00:00 2026-06-10T18:57:18+00:00

I am new to programming and I am teaching myself Python and as a

  • 0

I am new to programming and I am teaching myself Python and as a hobby I am making a text-based RPG.

My question is this; I want to store a list of weapons, armours etc that can be easily edited without screwing up my whole program. My thinking is that I make a separate module for them equipment.py and store them in a list like;

equipment = [ 
#Longsword
w1 = 15
#Axe
w2 = 17
]

I would just import this and use the values assigned to them would be used in whatever combat engine I decide to create. Is this even correct? Terrible coding conventions? I have much to learn and any wisdom you have to share is much appreciated.

EDIT: From the excellent answer below I have started it code it, how does my code look?

equipment = {

'Longsword':     {  'cost': 50,
                    'damage': 19,
                    'element': 'physical',
                    'description': 'Long steel blade used by the knights of Coamrin. The weight allows it to cleave foes with relative ease.'}

'Estoc':        {   'cost': 45,
                    'damage': 17,
                    'element': 'physical',
                    'description': 'Expertly crafted thin, steel blade designed for thrust and swiping motions.'}

}

Any tips? I have read through PEP 8 but my knowledge is not good enough or there is nothing specific enough to help in this particular case

  • 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-10T18:57:19+00:00Added an answer on June 10, 2026 at 6:57 pm

    I would suggest that using a python dictionary (rather than a list) would be preferable.

    equipment = {
                  'Longsword': 15,
                  'Axe':       17
                }
    

    That way you can refer to the longswords value as equipment['Longsword'] rather than by its position in the list equipment[0].

    Putting it in a separate module could be a good idea, perhaps inside a module containing the attack/defence functionality, and other items effects.

    .

    One other suggestion you might be interested in (depending on the RPG’s functionality) would be to have another dictionary for this and other attributes, so you could add other attributes in the future. That is,

    equipment = {
                 'Longsword': {'attack_str': 15, 'defence_str': 15, 'color': 'grey',... etc.}
                 }
    

    This allows additional functionality to be added later (without breaking previous mechanics).

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

Sidebar

Related Questions

I am in the process of teaching myself thread based programming techniques and this
Totally new to programming so kindly excuse the silly question. I have this URL
I think this is a very simple question, but I’m new to programming so
I'm new to the development world, I am gradually teaching myself programming after 15
I've been teaching myself Python at my new job, and really enjoying the language.
I am new to programming in general and have been teaching myself using Android
New to programming. I wrote a Python code (with help from stackoverflow) to read
I've been teaching myself F# for a while now. I've read Programming F# by
When I was first started teaching myself programming, after finishing a tutorial I would
I'm new programming in shell and I need some help with this code... Buildname=

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.