Can i use more than one break in the same while function? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

Can i use more than one break in the same while function?

For example: x = float(input("Enter the studiet grade: ")) while True: if x <= 50: print ("failed") break continue elif 50 < x <= 70: print ("good") break continue elif 70 < x <= 90: print ("very good ") break continue elif 90 < x <= 100: print ("Excellent") break else : print ("Grade must be smaller than 100") break

10th Jul 2016, 3:56 PM
Ahmed Kamal
Ahmed Kamal - avatar
4 ответов
0
@Rupam Das , but if i remove break it will be infinite loop what is the solution ???
12th Jul 2016, 5:15 AM
Ahmed Kamal
Ahmed Kamal - avatar
0
you can use multiple break statements .eg:inside if else statements. only one break statement is executed. was this helpful?
14th Jul 2016, 4:28 AM
nived punchayil
nived punchayil - avatar
0
for a time only one if condition will execute in your cord,so here you should break statements inside every if condition
15th Jul 2016, 3:17 PM
Charith
- 1
No you can not. If you use break while loop will be stopped than using continue wont work
11th Jul 2016, 11:09 AM
Rupam Das
Rupam Das - avatar