User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 429,994 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,392 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 34990 | Replies: 2
Reply
Join Date: Feb 2006
Posts: 6
Reputation: shafter111 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
shafter111 shafter111 is offline Offline
Newbie Poster

do-while loop in python

  #1  
Feb 19th, 2006
Hi.....I am a newbie...really confused with do while loop in python. Does it even exist?

 J=[]
    do:
        finished = "false"
        while finished != "true":
            finished="true"
            for j in xrange(len(lis2)):
                  cenP2 = G[i+G0]
                   if ((cenP2 == 0) & (sigma2 > 0)  
                          J.append(1)
                          finished = "false"
                          print 3 # test code never gets here
                   else:
                          finished="true"
                         print 4 




Sorry, I left out a few details caz its not important and just takes up space. My point is....how do I do this? I know this is not right, but is there a way?

Thanks a lot .....
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,477
Reputation: vegaseat will become famous soon enough vegaseat will become famous soon enough 
Rep Power: 10
Solved Threads: 176
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
Kickbutt Moderator

Re: do-while loop in python

  #2  
Feb 19th, 2006
No, there is no "do ... while" loop in Python. A properly constructed while loop can do the same.

If you have any problems, give us a simplified idea of what you want to accomplish. We will be glad to help!
May 'the Google' be with you!
Reply With Quote  
Join Date: Jun 2008
Posts: 1
Reputation: teci is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
teci teci is offline Offline
Newbie Poster

Re: do-while loop in python

  #3  
Jun 11th, 2008
from //kogs-www.informatik.uni-hamburg.de/~meine/python_tricks
  1. while True:
  2. do_something()
  3. if condition():
  4. break
Godspeed

Editors note:
For Python code on Daniweb:
Please use the [code=python] and [/code] tag pair to enclose your python code.
Last edited by vegaseat : Jun 11th, 2008 at 7:35 pm. Reason: added code tags
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Python Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Python Forum

All times are GMT -4. The time now is 12:46 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC