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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:45:30+00:00 2026-06-11T00:45:30+00:00

I have a ton of variables that I need to create and reference, for

  • 0

I have a ton of variables that I need to create and reference, for example diceOutCome2, diceOutCome4… diceOutCome12, diceOutComeHornHigh, diceOutComeHornFive, etc and I constanctly need to reference them so I wish to store them as global variables instead of passing them around as parameters.

Most importantly, I am also trying Not to reference them with index numbers but instead with names or property like counter.diceOutCome2… 2 here is not the number 2 outcome but outcome with dice rolled 1 and 1, four would store dice total with 2,2, 1,3 information etc.

What’s the most efficient way and the correct syntax to create them?

def setGlobalVariables():
    counter=[]
    for i in range (0, 12):
        global counter["count_"+i]=0
  • 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-11T00:45:32+00:00Added an answer on June 11, 2026 at 12:45 am

    For properties like “diceOutCome2”, you are actually better off using a list with index numbers, like counter.diceOutCome[2]. This allows you to easily iterate over all the list of diceOutcomes, or to refer to the outcome before the 5th dice outcome as counter.diceOutCome[n-1] when n is 5.

    Horn bets can be computed as methods on an object, either the counter object that you referenced before (counter.highHorn(5) could evaluate the winning or losing of a high horn bet on counter.diceOutcome[5]), or on the object used to represent the die roll outcome, a list of which is kept in diceOutCome, as in counter.diceOutcome[5].highHorn(). Or HighHorn could be an subclass of Bet; an instance of HighHorn is constructed using a DiceOutcome, and HighHorn would implement a wins() method, defined in abstract on Bet, to be implemented in subclasses – evaluating it as HighHorn(counter.diceOutCome[5]).wins(). Since the diceOutcomes are all attached to counter, then this might be a logical item to pass around to related methods, or a logical item on which to define those methods.

    In general, if you start thinking about defining variable names with trailing numeric digits, for instance that something1, something2, something3 are going to be of use in your program, you must immediately stop and replace with a list called somethings, and access them using list indices like somethings[2].

    (Note – For ease of communication, I am using 1-based indexing to correspond to the descriptions – in actuality, indexes to the items in a sequence are 0-based, hence the 5th item would really be referenced as sequence[4], the item before it is sequence[4-1], the 1st item being found atsequence[0]`. The point is, this is the case where indexes make sense, not numeric suffixes on variable names.)

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

Sidebar

Related Questions

Since I have a ton of IDisposable s that I need to take care
I have a ton of tables that vary in columns by a small amount.
I have a script that uses a ton of redirects. About half way through
Hello I have a WinForm app that generates a ton of data. Currently I
I have just started work on asmall program that sends text over net (TON)
I have a ton of files that are named like this: nn - xxxxxxxxxxxxxx-OOO.ext
I have a script that generates a ton of locations/places based on a users
I have a bunch of variables that I want to check, and if they
So, I have a heavy page that does a ton of JavaScript and has
I have a ton of data in a sql database which I would like

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.