Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #52031

Re: Creating a running tally/ definitely new to this

X-Received by 10.224.64.202 with SMTP id f10mr2532035qai.2.1375786831591; Tue, 06 Aug 2013 04:00:31 -0700 (PDT)
X-Received by 10.50.92.100 with SMTP id cl4mr38075igb.8.1375786831552; Tue, 06 Aug 2013 04:00:31 -0700 (PDT)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!f7no1337075qan.0!news-out.google.com!he10ni733qab.0!nntp.google.com!fx3no1393408qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Tue, 6 Aug 2013 04:00:30 -0700 (PDT)
In-Reply-To <mailman.225.1375754670.1251.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=108.67.176.40; posting-account=GNhYawoAAAABBvsQP9OJ_7fwfhZrIQwD
NNTP-Posting-Host 108.67.176.40
References <9e9e6a5a-5f8e-46b4-91dc-757fc74348d9@googlegroups.com> <mailman.225.1375754670.1251.python-list@python.org>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <591973bb-477e-48bd-a9a2-e644f342e1a8@googlegroups.com> (permalink)
Subject Re: Creating a running tally/ definitely new to this
From gratedmedia@gmail.com
Injection-Date Tue, 06 Aug 2013 11:00:31 +0000
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
Xref csiph.com comp.lang.python:52031

Show key headers only | View raw


Yes I want to store an amount of money which will change from many places within the code. Absolutely correct.  I am very "green" to this, if you're familiar, with "dopewars" the concept is very similar. 

for my practice trials I used.. selection_b = input()

 and manually input an amount of money, and used a loop of:

loop = 1
while loop < 5: 

just to get a feel of how it would work but, every time I travel to a new destination and buy something the amount of money is reset. And I am working to prevent this so that I can maintain a running tally until the loop is complete.   
> 
> 
> 
> 
> I currently working on a game, where I need to maintain a running tally of money, as the player makes purchases as they navigate thru game.   I not exactly sure how to do this in python.  I know it is a fairly basic step, nonetheless.  Any assistance would be greatly appreciated.
> 
> 
> 
> 
> 
> If I understand correctly you want to store the amount of money in a variable as a number that can be changed from many places within the code.
> 
> 
> Say you have:
> 
> 
> 
> 
>     money = 0
> 
> 
>     def do_some_adventuring():
>         ... # Add some money
> 
> 
> You can "add some money" with:
> 
> 
> 
>         global money # Allow changing money from within the function
> 
>         money += 10 # for example
> 
> 
> Is that it?
> 
> 
> ----
> 
> 
> Note that normally you'd have some class of player with a money attribute which can be accessed, but as a guess from the question I'm not sure you know about classes yet.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Creating a running tally/ definitely new to this gratedmedia@gmail.com - 2013-08-05 18:01 -0700
  Re: Creating a running tally/ definitely new to this Joshua Landau <joshua@landau.ws> - 2013-08-06 02:56 +0100
    Re: Creating a running tally/ definitely new to this gratedmedia@gmail.com - 2013-08-06 04:00 -0700
  Re: Creating a running tally/ definitely new to this Dave Angel <davea@davea.name> - 2013-08-06 02:15 +0000
    Re: Creating a running tally/ definitely new to this gratedmedia@gmail.com - 2013-08-06 08:24 -0700
      Re: Creating a running tally/ definitely new to this Joshua Landau <joshua@landau.ws> - 2013-08-07 13:02 +0100

csiph-web