Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repeat-until or equivalent loop in Python [duplicate]

Tags:

python

loops

I am a beginner in Python programming. I am trying to work on this algorithm that finds convex hull using Graham's scan method. However, in the pseudocode, there is a repeat ... until loop, which I could not figure out a way to write it in Python.

How do I write a repeat ... until loop in Python?

like image 275
Accay Hassan Avatar asked May 26 '13 11:05

Accay Hassan


People also ask

Is there a repeat until loop in Python?

The repeat / until loop is a loop that executes a block of statements repeatedly, until a given condition evaluates to true . The condition will be re-evaluated at the end of each iteration of the loop, allowing code inside the loop to affect the condition in order to terminate it.

How do you repeat a loop in Python?

The most common way to repeat a specific task or operation N times is by using the for loop in programming. We can iterate the code lines N times using the for loop with the range() function in Python.

How do you repeat code until a condition is met in Python?

A while loop will run a piece of code while a condition is True. It will keep executing the desired set of code statements until that condition is no longer True. A while loop will always first check the condition before running.


Video Answer


1 Answers

REPEAT     ... UNTIL cond 

Is equivalent to

while True:     ...     if cond:         break 
like image 124
John La Rooy Avatar answered Sep 21 '22 06:09

John La Rooy