301.10 Iteration
Practise exam questionsIteration — Note 2 of 4
Repeat while condition true.
A while loop repeats as long as its condition is True. The condition is checked before each iteration. Use it when you don't know in advance how many times to loop.
while condition: repeats while TrueFalseFalse → infinite looppassword = ""
while password != "secret":
password = input("Enter password: ")
print("Access granted")Specification notes for programming are in Paper 2.