PYTHON LESSON
while repeats until condition becomes False.
Update loop variable each round.
Infinite loops.
You will study while Loop. It belongs to the Logic phase.
Remember this:
while repeats until condition becomes False.
Practice step by step. Do not rush. Each run should show you something new.
Tip:
Update loop variable each round.
Avoid this:
Infinite loops.
Your challenge:
Countdown from 10 to 1.
Go to the challenge lab below. Fix errors until the output looks right. Then press the green button to complete the topic.
Copy this example if it helps. Change it so it matches while Loop.
# Topic: while Loop
def main():
sample = "edit me"
# TODO: apply while Loop concept here
result = sample
print("Result:", result)
if __name__ == "__main__":
main()
Countdown from 10 to 1.
Before you can finish: your output should include at least 8 characters; at least 1 non-empty line(s); must contain (letters can be upper or lower case): "10", "1"; no crash traceback—fix errors until the program runs cleanly.
Use Run. Read the output. Change your code until the task is done.
# Challenge starter for while Loop
def solve():
# Write your solution here
pass
print("Update solve() and run")
The first Run may load Python in your browser (one-time). Later runs are faster.