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


Groups > comp.lang.python > #44529

Re: repeat program

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'else:': 0.03; 'say,': 0.05; 'def': 0.12; 'bug': 0.12; 'random': 0.14; 'email addr:comcast.net': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'loops': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:program': 0.16; 'wrote:': 0.18; 'advance.': 0.19; 'skip:f 30': 0.19; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'replace': 0.24; 'player': 0.26; 'asking': 0.27; 'header:In-Reply-To:1': 0.27; "skip:' 10": 0.31; 'skip:c 30': 0.32; 'proceed': 0.33; 'received:84': 0.35; 'thanks': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'spot': 0.65; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'repeat': 0.74; "'for'": 0.84; "'while'": 0.84; 'again?': 0.84; 'reply-to:addr:python.org': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=JsTI8qIC c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=7AxPfEIvyrUA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=vQ5OG_FnXDAA:10 a=C_IRinGWAAAA:8 a=IxX_rom9CueKrWPxmNkA:9 a=wPNLvfGTeEIA:10 a=si9q_4b84H0A:10
X-AUTH mrabarnett:2500
Date Tue, 30 Apr 2013 01:43:08 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5
MIME-Version 1.0
To python-list@python.org
Subject Re: repeat program
References <6fa77892-53f8-4fe4-a00c-802d292a2cca@googlegroups.com>
In-Reply-To <6fa77892-53f8-4fe4-a00c-802d292a2cca@googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
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.1169.1367282589.3114.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1367282589 news.xs4all.nl 15924 [2001:888:2000:d::a6]:37541
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44529

Show key headers only | View raw


On 30/04/2013 01:22, eschneider92@comcast.net wrote:
> How do I make the following program repeat twice instead of asking whether the player wants to play again?
>
>
> import random
> import time
>
> def intro():
>      print('You spot 2 caves in the distance.')
>      print ('You near 2 cave entrances..')
>      time.sleep(1)
>      print('You proceed even nearer...')
>      time.sleep(1)
>
> def choosecave():
>      cave=''
>      while cave!='1' and cave !='2':
>          print('which cave?(1 or 2)')
>          cave=input()
>          return cave
>
> def checkcave(chosencave):
>      friendlycave=random.randint(1,2)
>      if chosencave==str(friendlycave):
>          print ('you win')
>      else:
>          print('you lose')
>
> playagain='yes'
> while playagain=='yes':
>      intro()
>      cavenumber=choosecave()
>      checkcave(cavenumber)
>      print('wanna play again?(yes no)')
>      playagain=input()
>
> Thanks in advance.
>
Replace the 'while' loop with a 'for' loop that loops twice.

By the way, there's a bug in 'choosecave': what happens if the user
enters, say, '3'?

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


Thread

repeat program eschneider92@comcast.net - 2013-04-29 17:22 -0700
  Re: repeat program Denis McMahon <denismfmcmahon@gmail.com> - 2013-04-30 00:33 +0000
  Re: repeat program Dave Angel <davea@davea.name> - 2013-04-29 20:38 -0400
  Re: repeat program MRAB <python@mrabarnett.plus.com> - 2013-04-30 01:43 +0100
  Re: repeat program Ian Kelly <ian.g.kelly@gmail.com> - 2013-04-29 19:46 -0600

csiph-web