loops | SoloLearn: Learn to code for FREE!

0

loops

what does it mean when your code outputs " Time limit exceeded "

9/1/2016 8:44:50 PM

Kuzzz

7 Answers

New Answer

+3

use break statement instead of any one continue statement.. since no break is used it enters into infinite loop i = 0 while True: i = i +1 if i == 2: print("Skipping 2") continue # use break here or if i == 5: print("Breaking") continue # use break here print(i) print("Finished") in general while statement has to Fail in order to exit the loop,.over here it never happens. eg : fix an limit and change while loop in accordance, like.. while not i == 10: on this case,.. when i iterates from 0-9, i will not be equal to 10 and at the same time we have issued 'not' in front of comparison statement. this means,.. while not False: # which is true when i becomes 10 while not True: # which is False, loop exit's

0

0

don't get you

0

what did u try exactly.. post ur code plz

0

i = 0 while True: i = i +1 if i == 2: print("Skipping 2") continue if i == 5: print("Breaking") continue print(i) print("Finished")

0

thanks

-1

Paste your code with that mistake here