Tagged: break
Everything tagged "break", newest first.
Python Coding Exercise #59: Underlining
A beginner Python exercise on loops, len() and string multiplication — keep asking for strings, print each one underlined with dashes of the same length, and stop when the user presses Enter on an empty line.
Python Coding Exercise #50: Working with Numbers
A beginner Python exercise on collecting statistics in a loop — read numbers until the user types zero, then print the count, the sum, the mean, and how many numbers were positive and negative.
Python Coding Exercise #49: Story
A beginner Python exercise on building a string inside a loop — collect words from the user until they type "end" or repeat the previous word, and learn how to remember the previous value.
Python Coding Exercise #48: The Next Leap Year
A beginner Python exercise on searching with a while loop — start from the year after the one entered, test each year against the leap year rule, and stop at the first one that fits.
Python Coding Exercise #47: PIN and Number of Attempts
A beginner Python exercise on loops and counters — keep asking for a PIN until it is correct, count the attempts, and print a different message when it takes only one try.
Python Coding Exercise #46: Repeat Password
A beginner Python exercise on loops and input — ask for a password once, then keep asking the user to repeat it until it matches, and learn which lines belong inside the loop and which outside.
Python Coding Exercise #45: Fix the Code: Countdown
A beginner Python debugging exercise on while True and break — a countdown stops after the first number because the break condition is the wrong way round, and the fix is one symbol.
Python Coding Exercise #44: Input Validation
A beginner Python exercise on loops and input validation — keep asking for numbers, reject negative ones, print the square root of positive ones, and stop when the user types zero.
Python Coding Exercise #43: Shall We Continue?
A beginner Python exercise on your first while loop — repeat a message until the user types "no", and learn how while True and break work together.