0

Can we use two break statement in python. For example I have given you a code and it works👇.

Import maths n = int(input("Enter number") x = math.sqrt(n) for i in range(2,n): if x%i==0: print("it is") break else: print("it is not prime") break

20th Oct 2020, 7:21 PM
zeeshan
zeeshan - avatar
1 Antwort
+ 2
yes you can use break statement. your code will iterate only once and break, because in if and else both you put break
20th Oct 2020, 7:24 PM
Shadoff
Shadoff - avatar