2

I've been given the pseudo-code:

REPEAT
    READ mark
UNTIL mark <= 100 and mark >= 0

It then continues on with various IF loops.

I need to reconstruct this code in Python, specifically using a REPEAT-UNTIL loop. I know how I can achieve this with a FOR or WHILE loop, but I haven't come across REPEAT-UNTIL in python before. Is this possible?

Thanks in advance.

Edit: this is an exam question. Would I lose marks if I use Python and use a while loop rather than using a different language that has REPEAT-UNTIL loops?

Oceanescence
  • 1,967
  • 3
  • 18
  • 28

1 Answers1

3

There isn't a loop like what you describe but I often resort to things like:

while True:
     if condition:
         break
     do_stuff()  #this line may not ever be reached

or:

while True:
     do_stuff()      # this line gets executed at least once
     if condition:
         break
Sheena
  • 15,590
  • 14
  • 75
  • 113