Re: while loop (Reposting On Python-List Prohibited)

2016-10-12 Thread BartC
On 12/10/2016 11:15, Peter Otten wrote: BartC wrote: On 12/10/2016 05:30, Lawrence D’Oliveiro wrote: On Wednesday, October 12, 2016 at 11:23:48 AM UTC+13, BartC wrote: while n>=x: n=n-1 print "*"* n else: print ("2nd loop exit n=",n,"x=",x) What is the difference between that

Re: while loop (Reposting On Python-List Prohibited)

2016-10-12 Thread Peter Otten
BartC wrote: > On 12/10/2016 05:30, Lawrence D’Oliveiro wrote: >> On Wednesday, October 12, 2016 at 11:23:48 AM UTC+13, BartC wrote: >>> while n>=x: >>> n=n-1 >>> print "*"* n >>> else: >>> print ("2nd loop exit n=",n,"x=",x) >> >> What is the difference between that and >> >> w

Re: while loop (Reposting On Python-List Prohibited)

2016-10-12 Thread BartC
On 12/10/2016 05:30, Lawrence D’Oliveiro wrote: On Wednesday, October 12, 2016 at 11:23:48 AM UTC+13, BartC wrote: while n>=x: n=n-1 print "*"* n else: print ("2nd loop exit n=",n,"x=",x) What is the difference between that and while n>=x: n=n-1 print "*"*

Re: while loop (Reposting On Python-List Prohibited)

2016-10-11 Thread BartC
On 11/10/2016 22:26, Lawrence D’Oliveiro wrote: On Wednesday, October 12, 2016 at 6:58:46 AM UTC+13, dhawan...@gmail.com wrote: Only first loop is executing not the second one? n=6 x=1 while x<=n: print("*"*x) x+=1 print('n=', n)

Re: while loop

2016-10-11 Thread Jussi Piitulainen
dhawanpawa...@gmail.com writes: > n=6 > x=1 > while x<=n: > print "*"*x > x+=1 > while n>=x: > n=n-1 > print "*"* n > > > Only first loop is executing not the second one? It's a basic fact about while loops that after the loop the condition is false. The two conditions x <= n a

Re: while loop

2016-10-11 Thread Michael Torrie
On 10/11/2016 11:58 AM, dhawanpawa...@gmail.com wrote: > > n=6 > x=1 > while x<=n: > print "*"*x > x+=1 > while n>=x: > n=n-1 > print "*"* n > > > Only first loop is executing not the second one? Did you try printing out the loop variable to see what it does and what it is aft

Re: while loop

2016-10-11 Thread Larry Martell
On Tue, Oct 11, 2016 at 1:58 PM, wrote: > > n=6 > x=1 > while x<=n: > print "*"*x > x+=1 > while n>=x: > n=n-1 > print "*"* n > > > Only first loop is executing not the second one? Because after the first loop n < x -- https://mail.python.org/mailman/listinfo/python-list

Re: while loop - multiple condition

2014-10-14 Thread Chris Angelico
On Wed, Oct 15, 2014 at 10:04 AM, giacomo boffi wrote: > Tim Chase writes: > >> On 2014-10-12 22:16, Marko Rauhamaa wrote: >>> is equivalent with >>> >>> while ans.lower()[0] != 'y': >>> ans = input('Do you like python?') >> >> And still better improved with >> >> while ans[:1].low

Re: while loop - multiple condition

2014-10-14 Thread giacomo boffi
Tim Chase writes: > On 2014-10-12 22:16, Marko Rauhamaa wrote: >> is equivalent with >> >> while ans.lower()[0] != 'y': >> ans = input('Do you like python?') > > And still better improved with > > while ans[:1].lower() != 'y': > ans = input('Do you like python?') yok is Turk

Re: while loop - multiple condition

2014-10-13 Thread Michael Torrie
On 10/13/2014 11:12 AM, Rustom Mody wrote: > On Monday, October 13, 2014 10:13:20 PM UTC+5:30, Rob Gaddi wrote: >> On Mon, 13 Oct 2014 09:26:57 -0700 (PDT) >> Rustom Mody wrote: > >>> On Monday, October 13, 2014 9:43:03 PM UTC+5:30, Rob Gaddi wrote: On Mon, 13 Oct 2014 09:56:02 +1100 St

Re: while loop - multiple condition

2014-10-13 Thread Rustom Mody
On Monday, October 13, 2014 10:13:20 PM UTC+5:30, Rob Gaddi wrote: > On Mon, 13 Oct 2014 09:26:57 -0700 (PDT) > Rustom Mody wrote: > > On Monday, October 13, 2014 9:43:03 PM UTC+5:30, Rob Gaddi wrote: > > > On Mon, 13 Oct 2014 09:56:02 +1100 > > > Steven D'Aprano wrote: > > > > When you have mul

Re: while loop - multiple condition

2014-10-13 Thread Rob Gaddi
On Mon, 13 Oct 2014 09:26:57 -0700 (PDT) Rustom Mody wrote: > On Monday, October 13, 2014 9:43:03 PM UTC+5:30, Rob Gaddi wrote: > > On Mon, 13 Oct 2014 09:56:02 +1100 > > Steven D'Aprano wrote: > > > When you have multiple clauses in the condition, it's easier to reason > > > about > > > them i

Re: while loop - multiple condition

2014-10-13 Thread Rustom Mody
On Monday, October 13, 2014 9:43:03 PM UTC+5:30, Rob Gaddi wrote: > On Mon, 13 Oct 2014 09:56:02 +1100 > Steven D'Aprano wrote: > > When you have multiple clauses in the condition, it's easier to reason about > > them if you write the clauses as positive statements rather than negative > > stateme

Re: while loop - multiple condition

2014-10-13 Thread Rob Gaddi
On Mon, 13 Oct 2014 09:56:02 +1100 Steven D'Aprano wrote: > > When you have multiple clauses in the condition, it's easier to reason about > them if you write the clauses as positive statements rather than negative > statements, that is, "something is true" rather than "something is not > true",

Re: while loop - multiple condition

2014-10-13 Thread Chris Angelico
On Mon, Oct 13, 2014 at 11:09 PM, Marko Rauhamaa wrote: > Chris Angelico : > >> Or, even simpler: Use an active condition. >> >> while input('Do you like python?') not in ('yes', 'y'): pass > > Instead of the traditional "pull" technology, you could take advantage > of the state-of-the-art "push"

Re: while loop - multiple condition

2014-10-13 Thread Chris Angelico
On Mon, Oct 13, 2014 at 11:10 PM, Skip Montanaro wrote: > On Mon, Oct 13, 2014 at 6:59 AM, Chris Angelico wrote: >> >> while input('Do you like python?') not in ('yes', 'y'): pass > > > Unfortunately, you probably have to account for people who SHOUT: > > while input('Do you like python?').lo

Re: while loop - multiple condition

2014-10-13 Thread Skip Montanaro
On Mon, Oct 13, 2014 at 6:59 AM, Chris Angelico wrote: > while input('Do you like python?') not in ('yes', 'y'): pass Unfortunately, you probably have to account for people who SHOUT: while input('Do you like python?').lower() not in ('yes', 'y'): pass Skip -- https://mail.python.org/m

Re: while loop - multiple condition

2014-10-13 Thread Marko Rauhamaa
Chris Angelico : > Or, even simpler: Use an active condition. > > while input('Do you like python?') not in ('yes', 'y'): pass Instead of the traditional "pull" technology, you could take advantage of the state-of-the-art "push" approach: print("You must love python -- everybody does!") Mar

Re: while loop - multiple condition

2014-10-13 Thread Chris Angelico
On Mon, Oct 13, 2014 at 7:31 PM, Gelonida N wrote: > Taking into account the Steven's suggestion about using the 'in' expression > it could be: > > > while True: > ans = input('Do you like python?') > if ans.lower() in ('yes', 'y'): > break Or, even simpler: Use an active conditio

Re: while loop - multiple condition

2014-10-13 Thread Gelonida N
On 10/12/2014 07:08 PM, Shiva wrote: while ans.lower() != 'yes' or ans.lower()[0] != 'y': ans = input('Do you like python?') I personally consider double negations less intuitive than following: while not( ans.lower() == 'yes' and ans.lower()[0] == 'y' ): Reading this line yoy would ha

Re: while loop - multiple condition

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 11:43 AM, Dennis Lee Bieber wrote: > ONE: Python uses short circuit evaluation: for an OR, the second > clause > is only looked at if the first clause is FALSE (for an AND, the first > clause has to be TRUE before the second is evaluated). Short-circuiting doesn't

Re: while loop - multiple condition

2014-10-12 Thread Steven D'Aprano
Tim Chase wrote: > On 2014-10-12 22:16, Marko Rauhamaa wrote: >> is equivalent with >> >> while ans.lower()[0] != 'y': >> ans = input('Do you like python?') > > And still better improved with > > while ans[:1].lower() != 'y': > ans = input('Do you like python?') The intenti

Re: while loop - multiple condition

2014-10-12 Thread Tim Chase
On 2014-10-12 22:16, Marko Rauhamaa wrote: > is equivalent with > > while ans.lower()[0] != 'y': > ans = input('Do you like python?') And still better improved with while ans[:1].lower() != 'y': ans = input('Do you like python?') in the event that len(ans)==0 (a situation whi

Re: while loop - multiple condition

2014-10-12 Thread Denis McMahon
On Sun, 12 Oct 2014 17:08:00 +, Shiva wrote: > while ans.lower() != 'yes' or ans.lower()[0] != 'y': while ans.lower() is not equal to "yes" or ans.lower()[0] is not equal to "y" the loop will continue to run Note that if ans.lower() == 'y', then the first clause ( ans.lower() != 'yes' )

Re: while loop - multiple condition

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 6:16 AM, Marko Rauhamaa wrote: > The corrected version > > while ans.lower() != 'yes' and ans.lower()[0] != 'y': > ans = input('Do you like python?') > > is equivalent with > > while ans.lower()[0] != 'y': It's true that the first part is redundant, but tr

Re: while loop - multiple condition

2014-10-12 Thread Marko Rauhamaa
Chris Angelico : > On Mon, Oct 13, 2014 at 4:59 AM, Shiva > wrote: >> Bit confusing to use in While loop - Should have used the 'and' condition >> instead of OR- then it works fine. >> for OR both condition need to be false to produce a false output and break >> the loop. > > Correct, what you're

Re: while loop - multiple condition

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 4:59 AM, Shiva wrote: > Bit confusing to use in While loop - Should have used the 'and' condition > instead of OR- then it works fine. > for OR both condition need to be false to produce a false output and break > the loop. Correct, what you're looking for here is indeed a

Re: while loop - multiple condition

2014-10-12 Thread Shiva
Bit confusing to use in While loop - Should have used the 'and' condition instead of OR- then it works fine. for OR both condition need to be false to produce a false output and break the loop. More of SET operations. Thanks, Shiva -- https://mail.python.org/mailman/listinfo/python-list

Re: while loop - multiple condition

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 4:21 AM, Shiva wrote: >> The loop will continue while either part is true - that's what "or" >> means. Is that what you intended it to be doing? >> >> ChrisA >> > > > Yes..however, the second part of the or condition doesn't get evaluated. > So if I enter a 'y' - I expe

Re: while loop - multiple condition

2014-10-12 Thread Roy Smith
In article , Shiva wrote: > Why is the second part of while condition not being checked? > > while ans.lower() != 'yes' or ans.lower()[0] != 'y': > ans = input('Do you like python?') > > > My intention is if either of the conditions are true the loop should break. > But the condition aft

Re: while loop - multiple condition

2014-10-12 Thread Shiva
> The loop will continue while either part is true - that's what "or" > means. Is that what you intended it to be doing? > > ChrisA > Yes..however, the second part of the or condition doesn't get evaluated. So if I enter a 'y' - I expect the second part to evaluate and the loop to break -

Re: while loop - multiple condition

2014-10-12 Thread Chris Angelico
On Mon, Oct 13, 2014 at 4:08 AM, Shiva wrote: > Why is the second part of while condition not being checked? > > while ans.lower() != 'yes' or ans.lower()[0] != 'y': > ans = input('Do you like python?') > > > My intention is if either of the conditions are true the loop should break. > But th

Re: While loop help

2013-04-10 Thread Larry Hudson
On 04/09/2013 11:44 PM, Larry Hudson wrote: On 04/09/2013 09:49 AM, thomasancill...@gmail.com wrote: So what would be the proper way to perform a loop of this program. I still can't quite figure out the best way to do it. My suggestion... (pseudocode) # Print a heading/introduction here w

Re: While loop help

2013-04-10 Thread rusi
On Apr 9, 8:47 pm, thomasancill...@gmail.com wrote: > ... and if you have any ideas for me to improve my coding that will prevent > me from learning > python in a sloppy way. I'd like to learn it correctly the first time! Not perhaps a direct answer... Anyways there is style in which python is b

Re: While loop help

2013-04-09 Thread Larry Hudson
On 04/09/2013 09:49 AM, thomasancill...@gmail.com wrote: So what would be the proper way to perform a loop of this program. I still can't quite figure out the best way to do it. My suggestion... (pseudocode) # Print a heading/introduction here while True: # Print menu, with an added

Re: While loop help

2013-04-09 Thread Chris Angelico
On Wed, Apr 10, 2013 at 6:59 AM, Walter Hurry wrote: > On Tue, 09 Apr 2013 16:12:34 -0400, Dave Angel wrote: > >> On 04/09/2013 03:35 PM, Walter Hurry wrote: >>> On Wed, 10 Apr 2013 02:10:29 +1000, Chris Angelico wrote: >>> On Wed, Apr 10, 2013 at 1:47 AM, wrote: > ... I'm not sure what

Re: While loop help

2013-04-09 Thread Walter Hurry
On Tue, 09 Apr 2013 16:12:34 -0400, Dave Angel wrote: > On 04/09/2013 03:35 PM, Walter Hurry wrote: >> On Wed, 10 Apr 2013 02:10:29 +1000, Chris Angelico wrote: >> >>> On Wed, Apr 10, 2013 at 1:47 AM, wrote: ... I'm not sure what version I'm using ... >>> >>> Try putting these lines into a

Re: While loop help

2013-04-09 Thread Dave Angel
On 04/09/2013 03:35 PM, Walter Hurry wrote: On Wed, 10 Apr 2013 02:10:29 +1000, Chris Angelico wrote: On Wed, Apr 10, 2013 at 1:47 AM, wrote: ... I'm not sure what version I'm using ... Try putting these lines into a Python script: import sys print(sys.version) That works (of course), b

Re: While loop help

2013-04-09 Thread Walter Hurry
On Wed, 10 Apr 2013 02:10:29 +1000, Chris Angelico wrote: > On Wed, Apr 10, 2013 at 1:47 AM, wrote: >> ... I'm not sure what version I'm using ... > > Try putting these lines into a Python script: > > import sys > print(sys.version) > That works (of course), but in every Python version I've s

Re: While loop help

2013-04-09 Thread jmfauth
On 9 avr, 15:32, thomasancill...@gmail.com wrote: > I'm new to learning python and creating a basic program to convert units of > measurement which I will eventually expand upon but im trying to figure out > how to loop the entire program. When I insert a while loop it only loops the > first 2 l

Re: While loop help

2013-04-09 Thread Dave Angel
On 04/09/2013 01:18 PM, thomasancill...@gmail.com wrote: sorry i just started using google groups, not really all that sure how to use it properly. IMHO, best way is to switch to a good email program, and mail your messages to comp.lang.python. That's after subscribing via http://mail.

Re: While loop help

2013-04-09 Thread Dave Angel
On 04/09/2013 12:57 PM, thomasancill...@gmail.com wrote: I responded before I saw this message, this was very helpful so I appreciate your quick and helpful responses. So do you think prompting for a string and then checking if the string is true is a good practice for something like this? Whe

Re: While loop help

2013-04-09 Thread Chris Angelico
On Wed, Apr 10, 2013 at 3:18 AM, wrote: > sorry i just started using google groups, not really all that sure how to use > it properly. The best way to use Google Groups is to not use it, frankly. Just subscribe to the mailing list in gmail; it has its own issues (eg it encourages top-posting by

Re: While loop help

2013-04-09 Thread thomasancilleri
sorry i just started using google groups, not really all that sure how to use it properly. -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop help

2013-04-09 Thread Dave Angel
On 04/09/2013 09:57 AM, thomasancill...@gmail.com wrote: On Tuesday, April 9, 2013 9:32:18 AM UTC-4, thomasa...@gmail.com wrote: I'm new to learning python and creating a basic program to convert units of measurement which I will eventually expand upon but im trying to figure out how to loop t

Re: While loop help

2013-04-09 Thread Chris Angelico
On Wed, Apr 10, 2013 at 2:57 AM, wrote: > I responded before I saw this message, this was very helpful so I appreciate > your quick and helpful responses. So do you think prompting for a string and > then checking if the string is true is a good practice for something like > this? When would c

Re: While loop help

2013-04-09 Thread thomasancilleri
I responded before I saw this message, this was very helpful so I appreciate your quick and helpful responses. So do you think prompting for a string and then checking if the string is true is a good practice for something like this? When would checking for true/false be necessary? -- http://ma

Re: While loop help

2013-04-09 Thread thomasancilleri
So what would be the proper way to perform a loop of this program. I still can't quite figure out the best way to do it. -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop help

2013-04-09 Thread Chris Angelico
On Wed, Apr 10, 2013 at 2:24 AM, wrote: > For system version I get this: > 2.7.2 (default, Oct 11 2012, 20:14:37) > [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] Lovely! Perfect. > But, what I don't understand exactly is the while statement. I've been > looking around a lo

Re: While loop help

2013-04-09 Thread Joel Goldstick
On Tue, Apr 9, 2013 at 12:24 PM, wrote: > For system version I get this: > 2.7.2 (default, Oct 11 2012, 20:14:37) > [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] > > Also, I understand what your saying about the continuation code. There's > no need for me to include it in eac

Re: While loop help

2013-04-09 Thread thomasancilleri
For system version I get this: 2.7.2 (default, Oct 11 2012, 20:14:37) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] Also, I understand what your saying about the continuation code. There's no need for me to include it in each if/else statement, I could just use it at the en

Re: While loop help

2013-04-09 Thread Chris Angelico
On Wed, Apr 10, 2013 at 1:47 AM, wrote: > ... I'm not sure what version I'm using ... Try putting these lines into a Python script: import sys print(sys.version) That, on any version of Python (back a fairly long way, Steven D'Aprano can probably say how far), will give you a line or so of out

Re: While loop help

2013-04-09 Thread Joel Goldstick
On Tue, Apr 9, 2013 at 11:47 AM, wrote: > Sorry I'm just starting to learn python and I'm not sure what version I'm > using to be quite honest. I just started typing it up in Komodo edit (Which > I'm not personally a fan in particular) I fixed the missing parenthesis > which fixed the invalid syn

Re: While loop help

2013-04-09 Thread thomasancilleri
Sorry I'm just starting to learn python and I'm not sure what version I'm using to be quite honest. I just started typing it up in Komodo edit (Which I'm not personally a fan in particular) I fixed the missing parenthesis which fixed the invalid syntax problem. Also, I apologize for submitting c

Re: While loop help

2013-04-09 Thread Chris Angelico
On Tue, Apr 9, 2013 at 11:58 PM, wrote: > Also I'm getting a invalid syntax next to my elif statements that i wasnt > getting before. why is this happening now? Ah! That's relating to the close parenthesis problem I mentioned. That's the exact issue I saw. When you get told about a problem, so

Re: While loop help

2013-04-09 Thread Chris Angelico
On Tue, Apr 9, 2013 at 11:32 PM, wrote: > I'm new to learning python and creating a basic program to convert units of > measurement which I will eventually expand upon but im trying to figure out > how to loop the entire program. When I insert a while loop it only loops the > first 2 lines. Ca

Re: While loop help

2013-04-09 Thread thomasancilleri
Also I'm getting a invalid syntax next to my elif statements that i wasnt getting before. why is this happening now? -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop help

2013-04-09 Thread thomasancilleri
On Tuesday, April 9, 2013 9:32:18 AM UTC-4, thomasa...@gmail.com wrote: > I'm new to learning python and creating a basic program to convert units of > measurement which I will eventually expand upon but im trying to figure out > how to loop the entire program. When I insert a while loop it only

Re: while loop with the condition used in the body

2010-02-24 Thread Gregory Ewing
Ulrich Eckhardt wrote: so why not: while as : ... and also: if as : ... This sort of thing has been suggested repeatedly in the past, and it's always been rejected. That's not likely to change. Look up the past threads for the reasons why. -- Greg -- http://mail.python.or

Re: while loop with the condition used in the body

2010-02-24 Thread Ulrich Eckhardt
Peter Otten wrote: > Duncan Booth wrote: >> for rq in incoming_requests(...): >>handle_request(rq) > > ...and a likely implementation would be > > def incoming_requests(...): > while True: > rq = ... # inlined version of get_request() > if not rq: > break >

Re: while loop with the condition used in the body

2010-02-24 Thread Peter Otten
Duncan Booth wrote: > Peter Otten <__pete...@web.de> wrote: > >> Ulrich Eckhardt wrote: >> >>> I'm looking for a way to write code similar to this C code: >>> >>> while(rq = get_request(..)) { >>> handle_request(rq); >>> } >>> >> Assuming get_request(...) is called with the same argum

Re: while loop with the condition used in the body

2010-02-24 Thread Duncan Booth
Peter Otten <__pete...@web.de> wrote: > Ulrich Eckhardt wrote: > >> I'm looking for a way to write code similar to this C code: >> >> while(rq = get_request(..)) { >> handle_request(rq); >> } >> > Assuming get_request(...) is called with the same arguments on each > iteration and uses

Re: while loop with the condition used in the body

2010-02-24 Thread Peter Otten
Ulrich Eckhardt wrote: > I'm looking for a way to write code similar to this C code: > > while(rq = get_request(..)) { > handle_request(rq); > } > > Currently I'm doing > > while True: > rq = get_request(...) > if not rq: > break > handle_request(rq) > >

Re: while loop with the condition used in the body

2010-02-24 Thread Arnaud Delobelle
Ulrich Eckhardt wrote: > Hi! > > I'm looking for a way to write code similar to this C code: > > while(rq = get_request(..)) { > handle_request(rq); > } > > Currently I'm doing > > while True: > rq = get_request(...) > if not rq: > break > handle_request(rq)

Re: While loop

2009-03-05 Thread J Kenneth King
Fab86 writes: > On Mar 5, 5:23 pm, Marco Mariani wrote: >> Fab86 wrote: >> > Is it possible to get the program to catch the exception, wait 10 >> > seconds, then carry of from where it was rather than starting again? >> >> something like this? probably works in PASCAL as well :) >> >> > i=0 >> >

Re: While loop

2009-03-05 Thread Fab86
On Mar 5, 5:49 pm, Fab86 wrote: > On Mar 5, 5:23 pm, Marco Mariani wrote: > > > > > Fab86 wrote: > > > Is it possible to get the program to catch the exception, wait 10 > > > seconds, then carry of from where it was rather than starting again? > > > something like this? probably works in PASCAL a

Re: While loop

2009-03-05 Thread Chris Rebert
On Thu, Mar 5, 2009 at 9:49 AM, Fab86 wrote: > On Mar 5, 5:23 pm, Marco Mariani wrote: >> Fab86 wrote: >> > Is it possible to get the program to catch the exception, wait 10 >> > seconds, then carry of from where it was rather than starting again? > using sleep and then continue just makes the s

Re: While loop

2009-03-05 Thread Andre Engels
On Thu, Mar 5, 2009 at 6:49 PM, Fab86 wrote: > On Mar 5, 5:23 pm, Marco Mariani wrote: >> Fab86 wrote: >> > Is it possible to get the program to catch the exception, wait 10 >> > seconds, then carry of from where it was rather than starting again? >> >> something like this? probably works in PASC

Re: While loop

2009-03-05 Thread Fab86
On Mar 5, 5:23 pm, Marco Mariani wrote: > Fab86 wrote: > > Is it possible to get the program to catch the exception, wait 10 > > seconds, then carry of from where it was rather than starting again? > > something like this? probably works in PASCAL as well :) > > > i=0 > > while i < len(stuff): > >

Re: While loop

2009-03-05 Thread Marco Mariani
Fab86 wrote: Is it possible to get the program to catch the exception, wait 10 seconds, then carry of from where it was rather than starting again? something like this? probably works in PASCAL as well :) i=0 while i < len(stuff): try: do_with(stuff[i]) except SomeError: s

Re: While loop

2009-03-05 Thread Tino Wildenhain
Hi, Fab86 wrote: Hello, I am currently working on my program which send queries to Yahoo and then saves them into a flatfile. The problem I have is that I need to conduct 200 searches and Yahoo typically times out during the search with an error. I have caught the error and told it to time.slee

Re: while-loop?

2008-05-28 Thread Marc 'BlackJack' Rintsch
On Wed, 28 May 2008 19:56:55 +0200, huub wrote: > Being a newbie with Python, I'm trying a short program with this: > > > <..> >> t = RoboInterface() > > <..> >> while not t.Digital(1): # while endpoint is not reached >> 15 pass > > However, it always hangs on the 'while', which I can

Re: While loop with "or"? Please help!

2007-01-25 Thread Daniel
2007-01-25 11:26:09 [EMAIL PROTECTED] wrote in message <[EMAIL PROTECTED]> > Hmm, my while loop with "or" doesn't seem to work as I want it to... > How do I tell the while loop to only accept "Y" or "y" or "N" or "n" > input from the str(raw_input)? > > Thank's in advance! > > Snippet of code:

Re: While loop with "or"? Please help!

2007-01-25 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > > On Jan 25, 11:26 am, [EMAIL PROTECTED] wrote: (snip) >> #Runs the buildfinder function >> usrinp = buildfinder() >> >> def buildwhiler(): >> >> while usrinp != "y" or "Y" or "N" or "n": PROBLEM >> print "Enter Y or N!" >> usr = str(raw_in

Re: While loop with "or"? Please help!

2007-01-25 Thread [EMAIL PROTECTED]
On Jan 25, 11:26 am, [EMAIL PROTECTED] wrote: > Hmm, my while loop with "or" doesn't seem to work as I want it to... > How do I tell the while loop to only accept "Y" or "y" or "N" or "n" > input from the str(raw_input)? > > Thank's in advance! > > Snippet of code: > > import os > > def buildfind

Re: While loop with "or"? Please help!

2007-01-25 Thread Paul Rubin
Peter Otten <[EMAIL PROTECTED]> writes: > > while not usrinp.lower() in "yn": > > But note that 'in' performs a substring search and therefore "yn" and "" > would be accepted as valid answers, too. Oh right, that's a recent change to the language, I think. OK: while not usrinp.lower() in list

Re: While loop with "or"? Please help!

2007-01-25 Thread Tim Williams
On 25/01/07, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Peter Otten a écrit : > > Bruno Desthuilliers wrote: > > > >> and simplified again thanks to Python 'in' operator: > >> while not usrinp.lower() in "yn": > > > > But note that 'in' performs a substring search and therefore "yn" and "" >

Re: While loop with "or"? Please help!

2007-01-25 Thread Bruno Desthuilliers
Peter Otten a écrit : > Bruno Desthuilliers wrote: > >> and simplified again thanks to Python 'in' operator: >> while not usrinp.lower() in "yn": > > But note that 'in' performs a substring search and therefore "yn" and "" > would be accepted as valid answers, too. Mmm, right. Thanks for the cor

Re: While loop with "or"? Please help!

2007-01-25 Thread Peter Otten
Bruno Desthuilliers wrote: > and simplified again thanks to Python 'in' operator: > while not usrinp.lower() in "yn": But note that 'in' performs a substring search and therefore "yn" and "" would be accepted as valid answers, too. Peter -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop with "or"? Please help!

2007-01-25 Thread Paul Rubin
[EMAIL PROTECTED] writes: > while usrinp != "y" or "Y" or "N" or "n": PROBLEM while userinp not in 'yYnN': ... Or maybe more generally: while userinp.lower() not in 'yn':# case independent test ... -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop with "or"? Please help!

2007-01-25 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > Hmm, my while loop with "or" doesn't seem to work as I want it to... > How do I tell the while loop to only accept "Y" or "y" or "N" or "n" > input from the str(raw_input)? > > Thank's in advance! > > Snippet of code: > > import os > > def buildfinder(): > os.s

Re: While loop with "or"? Please help!

2007-01-25 Thread Ravi Teja
> while usrinp != "y" or "Y" or "N" or "n": PROBLEM Correct way: while usrinp != "y" or usrinp != "Y" or usrinp != "N" or usrinp != "n": There has to be a boolean evaluation on both sides of or. Or in this case: while usrinp not in ['Y', 'y', 'N', 'n']: Ravi Teja. -- http://mail.p

Re: While loop - print several times but on 1 line.

2006-01-26 Thread bruno at modulix
Jeffrey Schwab wrote: > Danny wrote: > >> Great! It's been solved. >> >> The line, as Glaudio said has a "," at the end and that makes it go >> onto one line, thanks so much man! >> >> var = 0 >> while <= 5: >> print a[t[var]], >> var = var +1 >> prints perfectly, thanks so much guys. > >

Re: While loop - print several times but on 1 line.

2006-01-26 Thread bruno at modulix
Danny wrote: > I think I should paste some of the programs code a little more of what I > want... probably... > var = 0 > while var <= 5: > print a[t[var]] > var = var +1 > > a is a dectionary (very big) and t is a string of text. (if that's > important right now). It might be important

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Jeffrey Schwab
Danny wrote: > Great! It's been solved. > > The line, as Glaudio said has a "," at the end and that makes it go onto > one line, thanks so much man! > > var = 0 > while <= 5: > print a[t[var]], > var = var +1 > prints perfectly, thanks so much guys. Looping over indexes is kinda unpyth

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Sion Arrowsmith
Danny <[EMAIL PROTECTED]> wrote: >The programs output will be: >text >text >(etc) > >How could I make this print: texttexttexttexttext? >Ive researched and looked through google and so far I can't find >anything that will help (or revelent for that matter). I'm kind of surprised this isn't a FAQ

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Fredrik Lundh
Danny wrote: > Great! It's been solved. > > The line, as Glaudio said has a "," at the end and that makes it go onto > one line, thanks so much man! > > var = 0 > while <= 5: >print a[t[var]], >var = var +1 > prints perfectly, thanks so much guys. if you wanted spaces between the items, w

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Fredrik Lundh
Danny wrote: > I think I should paste some of the programs code a little more of what I > want... > > var = 0 > while var <= 5: > print a[t[var]] > var = var +1 > > a is a dectionary (very big) and t is a string of text. (if that's > important right now). > > I'm just trying to make the

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Danny
Great! It's been solved. The line, as Glaudio said has a "," at the end and that makes it go onto one line, thanks so much man! var = 0 while <= 5: print a[t[var]], var = var +1 prints perfectly, thanks so much guys. -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Claudio Grondi
Danny wrote: > I think I should paste some of the programs code a little more of what I > want... > > var = 0 > while var <= 5: > print a[t[var]] > var = var +1 > > a is a dectionary (very big) and t is a string of text. (if that's > important right now). > > I'm just trying to make th

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Danny
I think I should paste some of the programs code a little more of what I want... var = 0 while var <= 5: print a[t[var]] var = var +1 a is a dectionary (very big) and t is a string of text. (if that's important right now). I'm just trying to make the value of a[t[var]] print on one l

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Stefan Neumann
Danny wrote: > How could I make this print: texttexttexttexttext? > Ive researched and looked through google and so far I can't find > anything that will help (or revelent for that matter). I am not quite sure, if I simplify the problem but i thought about something like that: >>> prin

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Heiko Wundram
Danny wrote: > As a shortcut: print "text"*5 --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list

Re: While loop - print several times but on 1 line.

2006-01-26 Thread Diez B. Roggisch
Danny wrote: > Hello there. > > I'm creating a little text changer in Python. In the program there is a > while loop. The problem is that a while loop will have 1 print statement > and it will loop until it gets to the end of the text. > Example: > > num = 5 // Set num to 5 > while num >= 1: /