Logo
2

Write a Python program that iterates through a list of numbers. Use a loop to print each number, but skip any number that is divisible by 3..

full question is

Write a Python program that iterates through a list of numbers. Use a loop to print each number, but skip any number that is divisible by 3. If the program encounters a number greater than 30, it should break out of the loop.

davidmacagodavidmacago asked a year ago

·

Answers

2

here you go:

numbers = [2, 8, 15, 21, 25, 30, 35, 40]

for number in numbers:
    if number > 30:
        break

    if number % 3 == 0:
        continue

    print(number)

mentalmavensmentalmavens answered a year ago

Post your answer

Recommended Books

Reading books is a great way to learn. Here are some of the books we recommend.