ACTIVITY 20 / 50
Try as many times as you needCharge the robot
Let’s understand
A loop can move a value towards a target. It checks the condition before every repetition. If the condition is false at the start, the block never runs. After the loop, execution continues at the next unindented line.
Listen to the explanation
Example
n = 2
while n < 4:
n += 1
print(n)Read a charge from 0 to 10. Add 1 while it is below 10. Print it after the loop.
I need a hint
Place print after the loop, without indentation.
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.
Мой профиль