In Xcode, both in Objective-C and C, we have the while
loop.
int number = 5; while (number > 0){ NSLog(@"The number is %i",number--); }
The python equivalent is also while
Since we already understand the block, know sometimes as a suite in Python, while
loops in Python are very simple to use.
number = 5 while number > 0: number = number -1 print ('The number is ', number)
We can use break
in a loop to break execution. This is a valid loop if we need to test at the end of the loop
number = 5 while True: number = number -1 print ('The number is ', number) if number < 0: break
Leave a Reply