ACTIVITY 23 / 50
Try as many times as you needEvery second signal
Let’s understand
The % operator returns the remainder after division. If n % 2 equals 0, n is even. A condition inside a loop lets you react only on selected steps. This combines repetition with a decision.
Listen to the explanation
Example
print(7 % 3)Loop through 1 to 6. Print only the even numbers: 2, 4, 6.
I need a hint
range(1, 7) includes 6. Inside, check n % 2 == 0.
How to find an error
- Read the last line of the error message.
- Find the indicated line. Check quotes, parentheses and indentation.
- Change one thing and run again.
main.py
4 spaces
Your draft stays in this browser.
Result
PythonYour program’s output will appear here. Click Run.
Мой профиль