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


Groups > comp.lang.python > #51992

Re: Creating a running tally/ definitely new to this

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <joshua.landau.ws@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'python.': 0.02; 'yet.': 0.04; 'attribute': 0.07; 'cc:addr:python-list': 0.11; 'def': 0.12; 'tally': 0.16; '\xc2\xa0i': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'code.': 0.18; 'variable': 0.18; 'have:': 0.19; 'normally': 0.19; 'example': 0.22; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'fairly': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'player': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'appreciated.': 0.29; '----': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'class': 0.32; 'running': 0.33; 'guess': 0.33; 'skip:d 20': 0.34; 'basic': 0.35; 'classes': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'changing': 0.37; 'subject:new': 0.38; 'sure': 0.39; 'changed': 0.39; 'how': 0.40; 'august': 0.61; 'places': 0.64; 'to:addr:gmail.com': 0.65; 'within': 0.65; 'assistance': 0.66; 'money': 0.72; 'subject:this': 0.83; 'game,': 0.84; 'step,': 0.84; 'navigate': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=VCl4R2weVzNXcuUMXvIINa7J74tJMlHhKA1XGi/aTM8=; b=ZmKmWBwDogOi4pU779mI6MwLPHnXnX/P/z1UAXfH47r/ONAEMhQ2PTh3aPt7T35Gx7 F6rcJ7jCdGHp1OxfTa4SUfPhSxHE+JInAf2Fyzlu99wBJPly8/yL+vVzu+8/NN3UEtfm 90OaG04cONsR4C3PKSPkgkeeN7morPvldk33gzZJspXLSKYwIVp2Mb1mUih76g2M2Kxk kztUyPxU3r6ccXzlkXP9haBCP3EDbqenl9dV4C7fc1czTVW8SQAZbdMFvyxdyXucxneh YRr/xdM34lpPq/Xs1CqPtcTx2+f1fuQNX3x5CFE70qWWo6piUasPT0rmEc2FehAWB/J4 HjVQ==
X-Received by 10.112.33.205 with SMTP id t13mr164356lbi.22.1375754208658; Mon, 05 Aug 2013 18:56:48 -0700 (PDT)
MIME-Version 1.0
Sender joshua.landau.ws@gmail.com
In-Reply-To <9e9e6a5a-5f8e-46b4-91dc-757fc74348d9@googlegroups.com>
References <9e9e6a5a-5f8e-46b4-91dc-757fc74348d9@googlegroups.com>
From Joshua Landau <joshua@landau.ws>
Date Tue, 6 Aug 2013 02:56:08 +0100
X-Google-Sender-Auth h46Iy9YtJk_Rmiunf50wO5QwBMA
Subject Re: Creating a running tally/ definitely new to this
To gratedmedia@gmail.com
Content-Type multipart/alternative; boundary=14dae93d94b8e7cbcf04e33dbce8
Cc python-list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.225.1375754670.1251.python-list@python.org> (permalink)
Lines 70
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1375754670 news.xs4all.nl 15967 [2001:888:2000:d::a6]:52425
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:51992

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 6 August 2013 02:01, <gratedmedia@gmail.com> wrote:

>
> 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