ACTIVITY 48 / 50
Try as many times as you needYour control panel
Let’s understand
Combine a list, loop and condition. The program receives an energy budget and decides which devices it can activate in order. Each successful activation reduces the remaining budget. Track the state, not just the first answer.
Listen to the explanation
Example
# input → list → loop → decision → remaining energyRead energy. Visit costs = [3, 5, 2]. If affordable, subtract the cost and print ON; otherwise print WAIT. Finally print the remaining energy.
I need a hint
Put the check and subtraction inside for; the final print goes after the loop.
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.
Мой профиль