How to get back to the loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to get back to the loop?

while 1==1: i=int(input("number:")) assert(i<10), "your number is bigger than 10" well, how can i get back to the loop after an assertion error occured? edit: thanks for the answers. but i want to error be seen still. after the error, how can i get back to the loop? i tried "continue" statement after "finally:" but it didnt work.

15th Sep 2016, 3:40 AM
yasin
2 Answers
+ 1
while 1==1: i=int(input("number:")) try: assert(i<=10), "your number is bigger than 10" except AssertionError as e: print("Error: {0}".format(e.args[0]))
15th Sep 2016, 3:18 AM
Textobot
Textobot - avatar
0
assert(i<10, "anything")
15th Sep 2016, 3:21 AM
odko