Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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.045 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'else:': 0.03; 'subject:Python': 0.06; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'def': 0.12; 'jan': 0.12; 'before.': 0.16; 'luckily': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.18; 'rules': 0.22; 'header:User-Agent:1': 0.23; 'subject:Code': 0.24; 'player': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'skip:p 30': 0.29; 'another': 0.32; 'subject:the': 0.34; 'but': 0.35; 'false': 0.36; 'turn': 0.37; 'needed': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'structure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'above,': 0.60; 'card.': 0.60; 'ago,': 0.61; 'break': 0.61; 'received:173': 0.61; 'email addr:gmail.com': 0.63; 'card': 0.63; 'cards': 0.65; 'believe': 0.68; 'hand': 0.80; '(ie': 0.84; 'player.': 0.84; 'received:fios.verizon.net': 0.84; 'subject:else': 0.84; 'rank': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Python: Code is ignoring the if and else Date: Sat, 03 Aug 2013 01:04:56 -0400 References: <0b558115-68c4-460b-863c-fef4b844bb57@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 In-Reply-To: <0b558115-68c4-460b-863c-fef4b844bb57@googlegroups.com> 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: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375506317 news.xs4all.nl 15996 [2001:888:2000:d::a6]:38532 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51844 On 8/2/2013 10:24 PM, kevin4fong@gmail.com wrote: Looking at this again, I believe you actually had the structure almost right before. You want to look through *all* of the target players cards and if *none* of them match, (ie the search fails), you want to draw 1 card. What you were missing before is break or return def player_0_hitman(hit): for card in pHands[target_player]: if target_card[0] == card[0]: count = pHands[target_player].count(card) pHands[0].append(card) pHands[target_player].remove(card) ShowMessage("HIT: " + str(count) + " card(s) transferred") return True # else: needed if just break above, but not with return top_card = GetTopCard(sDeck) pHands[0].append(top_card) if top_card[0] == target_card[0]: ShowMessage("HIT: LUCKILY Player 0 has fished up a rank <" + str(top_card[0]) + ">!!!") return True else: ShowMessage("MISS: You fished up the rank <" + str(top_card[0]) + ">") hit = hit - 1 return False The returns are based on what I remember of the rules from decades ago, that a hit either in the hand or the draw allowed another turn by the player. -- Terry Jan Reedy