dev-resources.site
for different kinds of informations.
Understanding the Usage of break and continue Keywords
break āĻāĻŦāĻ continue āĻā§āĻā§āĻžāĻ°ā§āĻĄā§āĻ° āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻĻā§āĻāĻžāĻ¨ā§āĻ° āĻāĻ¨ā§āĻ¯ āĻāĻŽāĻ°āĻž āĻāĻāĻāĻŋ āĻāĻĻāĻžāĻšāĻ°āĻŖ āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻāĻ°āĻŦ āĻ¯āĻž āĻāĻĒāĻ¨āĻžāĻ° āĻŦāĻžāĻ¸ā§āĻ¤āĻŦ āĻā§āĻŦāĻ¨ā§āĻ° āĻĒā§āĻ°āĻŦāĻ˛ā§āĻŽā§āĻ° āĻ¸āĻžāĻĨā§ āĻŽāĻŋāĻ˛ āĻ°ā§āĻā§ āĻ¤ā§āĻ°āĻŋ āĻāĻ°ā§āĻāĻŋāĨ¤
Break
āĻāĻĒāĻ¨āĻŋ āĻāĻāĻāĻŋ āĻ˛āĻāĻžāĻ°āĻŋāĻ° āĻāĻŋāĻāĻŋāĻ āĻāĻŋāĻ¨ā§āĻā§āĻ¨ āĻāĻŦāĻ āĻāĻāĻāĻŋ āĻ¨āĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āĻ āĻ¨āĻŽā§āĻŦāĻ° āĻĒāĻžāĻāĻ¯āĻŧāĻžāĻ° āĻ¸āĻžāĻĨā§ āĻ¸āĻžāĻĨā§ āĻā§āĻ˛āĻž āĻĨāĻžāĻŽāĻžāĻ¤ā§ āĻšāĻŦā§āĨ¤ āĻ¯āĻĻāĻŋ āĻāĻĒāĻ¨āĻŋ ā§ āĻ¨āĻŽā§āĻŦāĻ°āĻāĻŋ āĻĒāĻžāĻ¨, āĻ¤āĻžāĻšāĻ˛ā§ āĻā§āĻ˛āĻž āĻĨāĻžāĻŽāĻŦā§āĨ¤
tickets = [1, 3, 5, 7, 9, 11, 13]
lucky_number = 7
found = False
for ticket in tickets:
if ticket == lucky_number:
found = True
break # āĻ˛ā§āĻĒ āĻĨā§āĻā§ āĻŦā§āĻ°āĻŋāĻ¯āĻŧā§ āĻ¯āĻžāĻŦā§āĻ¨ āĻāĻžāĻ°āĻŖ āĻ˛āĻžāĻāĻŋ āĻ¨āĻŽā§āĻŦāĻ° āĻĒāĻžāĻāĻ¯āĻŧāĻž āĻā§āĻā§āĨ¤
print(f"Checked ticket: {ticket}")
if found:
print("Lucky number found!")
else:
print("Lucky number not found.")
Continue
āĻāĻāĻāĻŋ āĻĒāĻ°ā§āĻā§āĻˇāĻžāĻ° āĻāĻžāĻ¤āĻž āĻŽā§āĻ˛ā§āĻ¯āĻžāĻ¯āĻŧāĻ¨ āĻāĻ°āĻā§āĻ¨ āĻ¯ā§āĻāĻžāĻ¨ā§ āĻĒā§āĻ°āĻ¤āĻŋāĻāĻŋ āĻāĻžāĻ¤ā§āĻ°ā§āĻ° āĻ¨āĻŽā§āĻŦāĻ° āĻ¯āĻžāĻāĻžāĻ āĻāĻ°āĻ¤ā§ āĻšāĻŦā§āĨ¤ āĻ¯āĻĻāĻŋ āĻā§āĻ¨ā§ āĻāĻžāĻ¤ā§āĻ°ā§āĻ° āĻ¨āĻŽā§āĻŦāĻ° ā§Šā§Š-āĻāĻ° āĻāĻŽ āĻšāĻ¯āĻŧ, āĻ¤āĻžāĻšāĻ˛ā§ āĻ¤āĻžāĻā§ āĻĢā§āĻ˛ āĻšāĻŋāĻ¸ā§āĻŦā§ āĻāĻŋāĻšā§āĻ¨āĻŋāĻ¤ āĻāĻ°ā§ āĻĒāĻ°āĻŦāĻ°ā§āĻ¤ā§ āĻāĻžāĻ¤ā§āĻ°ā§āĻ° āĻ¨āĻŽā§āĻŦāĻ° āĻĻā§āĻāĻ¤ā§ āĻšāĻŦā§, āĻāĻŋāĻ¨ā§āĻ¤ā§ āĻā§āĻ¨ā§ āĻā§āĻ°ā§āĻĄ āĻ¯ā§āĻ āĻāĻ°āĻž āĻšāĻŦā§ āĻ¨āĻžāĨ¤
scores = [45, 67, 29, 75, 33, 48, 55]
passing_score = 33
total_score = 0
num_passed = 0
for score in scores:
if score < passing_score:
print(f"Score {score} is below passing mark.")
continue # āĻāĻ āĻāĻžāĻ¤ā§āĻ°ā§āĻ° āĻ¸ā§āĻā§āĻ° āĻ¯ā§āĻ āĻ¨āĻž āĻāĻ°ā§ āĻĒāĻ°āĻŦāĻ°ā§āĻ¤ā§ āĻāĻžāĻ¤ā§āĻ°ā§āĻ° āĻāĻžāĻā§ āĻ¯āĻžāĻŦā§āĻ¨āĨ¤
total_score += score
num_passed += 1
if num_passed > 0:
average_score = total_score / num_passed
else:
average_score = 0
print("Average Score of Passed Students:", average_score)
āĻāĻ āĻāĻĻāĻžāĻšāĻ°āĻŖāĻā§āĻ˛āĻŋ āĻŦāĻžāĻ¸ā§āĻ¤āĻŦ āĻā§āĻŦāĻ¨ā§āĻ° āĻŦāĻŋāĻāĻŋāĻ¨ā§āĻ¨ āĻ¸āĻŽāĻ¸ā§āĻ¯āĻžāĻ¯āĻŧ break āĻāĻŦāĻ continue āĻā§āĻā§āĻžāĻ°ā§āĻĄā§āĻ° āĻŦā§āĻ¯āĻžāĻŦāĻšāĻžāĻ° āĻĻā§āĻāĻžāĻ¯āĻŧāĨ¤ āĻāĻāĻāĻžāĻŦā§ āĻāĻĒāĻ¨āĻŋ āĻŦāĻŋāĻāĻŋāĻ¨ā§āĻ¨ āĻ¸āĻŽāĻ¸ā§āĻ¯āĻžāĻ¯āĻŧ āĻāĻ āĻĻā§āĻāĻŋ āĻā§āĻāĻ¯āĻŧāĻžāĻ°ā§āĻĄ āĻā§āĻāĻžāĻŦā§ āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻāĻ°āĻŦā§āĻ¨ āĻ¤āĻž āĻŦā§āĻāĻ¤ā§ āĻĒāĻžāĻ°ā§āĻ¨āĨ¤
Featured ones: