Write Python. Understand every error.

Starting Python in your browser…

Project

Number guessing game

Build a guessing game step by step: compare guesses, loop until correct, and count the tries.

  1. The first input line is the secret number and the second is a guess. Print Too low, Too high or Correct!.
  2. Now keep asking for guesses in a while loop until the guess is correct, printing Too low or Too high after each wrong guess and Correct! at the end.
  3. Count the guesses. After Correct!, print You needed N guesses (N includes the correct guess).

Ctrl + Enter to run
Line 1, column 1Tab indents 4 spaces. Press Esc then Tab to leave the editor.