Use break statement to break the loop if the current number is greater than 500
use continue statement move to next number if the current number is greater than 150
Use number % 5 == 0 condition to check if number is divisible by 5
Solution:
numbers = [12, 75, 150, 180, 145, 525, 50]
# iterate each item of a list
for item in numbers:
if item > 500:
break
elif item > 150:
continue
# check if number is divisible by 5
elif item % 5 == 0:
print(item)
Hint:
break
statement to break the loop if the current number is greater than 500continue
statement move to next number if the current number is greater than 150umber % 5 == 0
condition to check if number is divisible by 5Solution:
need an explanation for this answer? contact us directly to get an explanation for this answer