Re: [Tutor] Repeat Until Dead

2013-06-26 Thread Alan Gauld
On 26/06/13 23:07, Danilo Chilene wrote: Hello, Try something like this: coin = raw_input('Insert coins:\n') while(coin > 0): coin = int(coin)-1 print 'You have {0} coin(s)'.format(coin) Note you did not convert the original raw_input value to an int. Also you keep on converting co

Re: [Tutor] Repeat Until Dead

2013-06-26 Thread Danilo Chilene
Hello, Try something like this: coin = raw_input('Insert coins:\n') while(coin > 0): coin = int(coin)-1 print 'You have {0} coin(s)'.format(coin) $ python teste.py Insert coins: 2 You have 1 coin(s) You have 0 coin(s) On Wed, Jun 26, 2013 at 3:30 PM, Chris “Kwpolska” Warrick < kwpol.

Re: [Tutor] Repeat Until Dead

2013-06-26 Thread Marc Tompkins
On Wed, Jun 26, 2013 at 11:23 AM, Jack Little wrote: > In a combat system, how would I have a certain raw_input repeat until the > enemy is dead? > Sounds like a classic case for a "while" loop. ___ Tutor maillist - Tutor@python.org To unsubscribe or c

[Tutor] Repeat Until Dead

2013-06-26 Thread Jack Little
In a combat system, how would I have a certain raw_input repeat until the enemy is dead? Thanks a ton, Jack___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] repeat a sequence in range

2012-02-12 Thread Peter Otten
Michael Lewis wrote: > I am trying to repeat a certain sequence in a range if a certain even > occurs. Forgive me for not pasting my code; but I am not at the machine > where it's saved. > > Basically, I want to get user input and append that input to a list only > if the input is not already in

Re: [Tutor] repeat a sequence in range

2012-02-11 Thread Dave Angel
On 02/11/2012 06:22 PM, Michael Lewis wrote: I am trying to repeat a certain sequence in a range if a certain even occurs. Forgive me for not pasting my code; but I am not at the machine where it's saved. Basically, I want to get user input and append that input to a list only if the input is no

[Tutor] repeat a sequence in range

2012-02-11 Thread Michael Lewis
I am trying to repeat a certain sequence in a range if a certain even occurs. Forgive me for not pasting my code; but I am not at the machine where it's saved. Basically, I want to get user input and append that input to a list only if the input is not already in the list. I want to do this x amou

Re: [Tutor] Repeat function until...

2010-06-23 Thread Nethirlon
On Wed, Jun 23, 2010 at 10:13 PM, Steven D'Aprano wrote: > On Thu, 24 Jun 2010 04:09:38 am Alan Gauld wrote: >> "Steven D'Aprano" wrote >> >> > The easiest way is to just run forever, and stop when the user >> > interrupts it with ctrl-D (or ctrl-Z on Windows): >> >> I think that would be Ctrl-C

Re: [Tutor] Repeat function until...

2010-06-23 Thread Steven D'Aprano
On Thu, 24 Jun 2010 04:09:38 am Alan Gauld wrote: > "Steven D'Aprano" wrote > > > The easiest way is to just run forever, and stop when the user > > interrupts it with ctrl-D (or ctrl-Z on Windows): > > I think that would be Ctrl-C on both. > Ctrl-D/Z is EOF not Interrupt. Certainly on Windows Ctr

Re: [Tutor] Repeat function until...

2010-06-23 Thread Sithembewena Lloyd Dube
My code has two bugs. If any command other than an int is entered, it falls over ungracefully. Also, if any integers other than 1 or 0 are entered successively it exits the Python interpreter. I thought I would point this out so as not to mislead the OP. On Wed, Jun 23, 2010 at 8:09 PM, Alan Gaul

Re: [Tutor] Repeat function until...

2010-06-23 Thread Alan Gauld
"Steven D'Aprano" wrote The easiest way is to just run forever, and stop when the user interrupts it with ctrl-D (or ctrl-Z on Windows): I think that would be Ctrl-C on both. Ctrl-D/Z is EOF not Interrupt. Certainly on Windows Ctrl-Z won't interrupt a loop. But the principle is good and

Re: [Tutor] Repeat function until...

2010-06-23 Thread Dave Angel
Steven D'Aprano wrote: On Wed, 23 Jun 2010 10:29:11 pm Nethirlon . wrote: Hello everyone, I'm new at programming with python and have a question about how I can solve my problem the correct way. Please forgive my grammar, English is not my primary language. I'm looking for a way to repeat

Re: [Tutor] Repeat function until...

2010-06-23 Thread Sithembewena Lloyd Dube
^^ I meant time.sleep(x), rather. Please excuse the double post. On Wed, Jun 23, 2010 at 4:29 PM, Sithembewena Lloyd Dube wrote: > My two cents' worth added below. Seems to do what you want. You probably > want to call sys.wait(x) after printing an error, so it can be read before > exiting? > > i

Re: [Tutor] Repeat function until...

2010-06-23 Thread Sithembewena Lloyd Dube
My two cents' worth added below. Seems to do what you want. You probably want to call sys.wait(x) after printing an error, so it can be read before exiting? import os, sys, time def check(host): try: output = os.popen('ping -ns 1 %s' % host).read() alive = output.find('Reply fro

Re: [Tutor] Repeat function until...

2010-06-23 Thread Emile van Sebille
On 6/23/2010 6:51 AM Steven D'Aprano said... # untested def call_again(n, func, *args): """call func(*args) every n seconds until ctrl-D""" import time try: while 1: start = time.time() func(*args) time.sleep(n - (time.time()-start))

Re: [Tutor] Repeat function until...

2010-06-23 Thread Steven D'Aprano
On Wed, 23 Jun 2010 10:29:11 pm Nethirlon . wrote: > Hello everyone, > > I'm new at programming with python and have a question about how I > can solve my problem the correct way. Please forgive my grammar, > English is not my primary language. > > I'm looking for a way to repeat my function every

Re: [Tutor] Repeat function until...

2010-06-23 Thread Adam Bark
On 23 June 2010 13:29, Nethirlon . wrote: > Hello everyone, > > I'm new at programming with python and have a question about how I can > solve my problem the correct way. Please forgive my grammar, English > is not my primary language. > > I'm looking for a way to repeat my function every 30 seco

[Tutor] Repeat function until...

2010-06-23 Thread Nethirlon .
Hello everyone, I'm new at programming with python and have a question about how I can solve my problem the correct way. Please forgive my grammar, English is not my primary language. I'm looking for a way to repeat my function every 30 seconds. As an example I have written a ping function. But

Re: [Tutor] repeat

2007-11-17 Thread Scott Sandeman-Allen
On 11/17/07, bob gailer ([EMAIL PROTECTED]) wrote: >Michael wrote: >> Hi All >> >> This has probably been asked before but can I get some clarification on >> why Python does not have a repeat...until statement, and does that mean >> repeat...until is bad practice? I was trying to get Python on t

[Tutor] repeat

2007-11-17 Thread Michael H. Goldwasser
On Saturday November 17, 2007, Michael wrote: >Hi All > >This has probably been asked before but can I get some clarification on >why Python does not have a repeat...until statement, and does that mean >repeat...until is bad practice? I was trying to get Python on the >

Re: [Tutor] repeat

2007-11-17 Thread bob gailer
Michael wrote: > Hi All > > This has probably been asked before but can I get some clarification on > why Python does not have a repeat...until statement, and does that mean > repeat...until is bad practice? I was trying to get Python on the > standard langauge list for my state secondary school

Re: [Tutor] repeat

2007-11-17 Thread Alan Gauld
"Michael" <[EMAIL PROTECTED]> wrote > This has probably been asked before but can I get some clarification > on > why Python does not have a repeat...until statement, Because Guido didn't put one in repeat/until is never needed it is only ever a nice to have. Indeed some languages don't even ha

Re: [Tutor] repeat

2007-11-17 Thread Scott SA
On 11/17/07, Michael ([EMAIL PROTECTED]) wrote: >This has probably been asked before but can I get some clarification on >why Python does not have a repeat...until statement, and does that mean >repeat...until is bad practice? I was trying to get Python on the >standard langauge list for my sta

[Tutor] repeat

2007-11-16 Thread Michael
Hi All This has probably been asked before but can I get some clarification on why Python does not have a repeat...until statement, and does that mean repeat...until is bad practice? I was trying to get Python on the standard langauge list for my state secondary school system but they say a la