While Loop & Exit
March 12, 2018
A simple script that asks a user to guess the number. It uses a while loop that will continue to ask for user input until the condition is met. We then use exit() to break the loop.
from sys import exit
while True:
print "Try and guess the number."
guess = raw_input("> ")
if guess == "7":
print "You guessed correctly."
exit(0)
else:
print "Wrong."
Recent Entries
- Filter First, Think Later February 21, 2026
- Five Hundred Bugs That Fuzzers Missed February 20, 2026
- Gemini 3.1 Pro and the 0.1 That Matters February 19, 2026