Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'variables': 0.07; 'alter': 0.09; 'defines': 0.09; 'doing?': 0.09; 'cc:addr :python-list': 0.11; 'def': 0.12; 'wrote': 0.14; 'random': 0.14; 'changes': 0.15; 'kris': 0.16; 'parentheses': 0.16; 'path.': 0.16; 'true),': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'import': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; "shouldn't": 0.24; 'guys': 0.24; 'cc:2**0': 0.24; 'player': 0.26; 'defined': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'fixed': 0.29; 'message- id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'serve': 0.31; 'parameters.': 0.31; 'run': 0.32; 'another': 0.32; 'url:python': 0.33; 'subject:with': 0.35; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'functions.': 0.36; 'skip:+ 70': 0.36; 'url:listinfo': 0.36; 'next': 0.36; 'url:org': 0.36; 'should': 0.36; 'two': 0.37; 'pm,': 0.38; 'explain': 0.39; 'does': 0.39; 'bad': 0.39; 'url:mail': 0.40; 'how': 0.40; 'subject:back': 0.60; 'stand': 0.64; 'subject:more': 0.64; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'incorporate': 0.68; 'battle.': 0.84; 'joel': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=5pv8Yio4IGYmC5iLeu+N3nW2O2wyyD0Oljzsq7tU6Rk=; b=TcTv5jTZJcadJWKVUaHFgDyI6yJwQsNwGLqnMXmn406gnMhbj4uZtUYoJmeoahaIxG Oh+9PscHgsUKQRs21DSbttFSdHkHfrSwN7kETRB1RQohb5GwRCf7EVxRaQRdDSGMznCM sO1tBaCxfUj9Q5WIUA/bRbJ7aahRy3eTmMg6XRuxOwpH6X2vjovOj0x9h0khAXBPQiyl GxIP8uKBemFP4mONFpqnF0lpSyfBTg3PG8V0LpcSUV7AUiEsMqvVOFp7vO5CqJ7nA7PU 81IhOzDgz4VyQU+x60g2hLrXRgHXi8TQdJffEYIx/w1LMCSmcq7sHMM8ZkAHckkY4n/9 VWew== MIME-Version: 1.0 X-Received: by 10.52.117.79 with SMTP id kc15mr4645239vdb.45.1376281263228; Sun, 11 Aug 2013 21:21:03 -0700 (PDT) In-Reply-To: References: Date: Mon, 12 Aug 2013 00:21:03 -0400 Subject: Re: back with more issues From: Joel Goldstick To: Kris Mesenbrink Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: "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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 64 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1376281271 news.xs4all.nl 15870 [2001:888:2000:d::a6]:48063 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52399 On Sun, Aug 11, 2013 at 11:33 PM, Kris Mesenbrink wrote: > import random > > def player(): > hp =3D 10 > speed =3D 5 > attack =3D random.randint(0,5) # add the following line to return attack value: return attack > > def monster (): > hp =3D 10 > speed =3D 4 > > def battle(player): > print ("a wild mosnter appered!") > print ("would you like to battle?") > answer =3D input() > if answer =3D=3D ("yes"): you don't need the parentheses around "yes" > return player(attack) you can't do that above because you defined the function with no parameters. If you alter player to return attack you can alter the above line to: return player() > else: > print("nope") Its a bad idea to have a function return something down one path (If True), then return nothing down another path. > > > battle() > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++= + > > this was a variation on a code that you guys already had helped me with,i= n the long run i plan to incorporate them together but as it stand i don't = know how to call a specific variable from one function (attack from player)= to use in another function (battle). what i want is to be able to use the = variables from both player and monster to use in battle. any idea's? I wrote some quick changes above to give you what you want. But you need to understand more about functions. Your player function does next to nothing. It defines two variables to fixed values, then gets a random number and returns it. Can you try to explain what you think each of your functions is doing? Every line should serve a purpose, or it shouldn't be in the function. > -- > http://mail.python.org/mailman/listinfo/python-list --=20 Joel Goldstick http://joelgoldstick.com