V.Vidhya Logo

V.Vidhya

Lucky Number Game


Create a “Guess the Lucky Number” game.

As the admin, set a “lucky number” between 1 and 100 in your program. The user (player) will attempt to guess this number.

Instructions

The program should repeatedly prompt the user for a guess until they either:

  • Correctly match the lucky number.
  • Enter 0 to exit the game (at any time).
  • The player uses up all 10 allowed guesses

To help the player, provide hints after each guess:

  • If the guess is larger than the lucky number, display a message indicating it is too high.
  • If the guess is smaller, indicate it is too low.

This feedback allows the player to narrow down their guesses and find the lucky number.

Expected Output
// lucky number: 25

Guess the lucky number: 87   // user input
Your guessed number is larger than the lucky number. Try Again.   // hint

Guess the lucky number: 17   // user input
Your guessed number is smaller than the lucky number. Try Again.

Guess the lucky number: 45   // user input
Your guessed number is larger than the lucky number. Try Again.

Guess the lucky number: 25   // user input
Congratulations, you have guessed the lucky number.


Feel free to implement additional features to enhance the gameplay.


Next Post
Nim Game