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: 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>': 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 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 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 --14dae93d94b8e7cbcf04e33dbce8 Content-Type: text/plain; charset=UTF-8 On 6 August 2013 02:01, 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. --14dae93d94b8e7cbcf04e33dbce8 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 6 August 2013 02:01, <gratedmedia@gmail.com&g= t; wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">
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. =C2=A0 I n= ot exactly sure how to do this in python. =C2=A0I know it is a fairly basic= step, nonetheless. =C2=A0Any assistance would be greatly appreciated.

If I understand correctly you want to stor= e the amount of money in a variable as a number that can be changed from ma= ny places within the code.

Say you have:

=C2=A0 =C2=A0 money =3D 0

=C2= =A0 =C2=A0 def do_some_adventuring():
=C2=A0 =C2=A0 =C2=A0 =C2=A0= ... # Add some money

You can "add some money= " with:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 global money # Allow changing money from within= the function
=C2=A0 =C2=A0 =C2=A0 =C2=A0 money +=3D 10 # for example

=
Is that it?

----

Note that normally you'd have some class of player with a money attr= ibute which can be accessed, but as a guess from the question I'm not s= ure you know about classes yet.
--14dae93d94b8e7cbcf04e33dbce8--