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
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.
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
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
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
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
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
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
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
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
"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
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
^^ 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
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
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))
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
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
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
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
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
>
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
"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
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
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
24 matches
Mail list logo