Skip to content

Latest commit

 

History

History
15 lines (8 loc) · 1008 Bytes

README.md

File metadata and controls

15 lines (8 loc) · 1008 Bytes

Python Guessing Game

This is a fun little project that I like to do in my spare time. It is a number-guessing game written in Python. The basic idea is to have the computer produce a random number between 1 and 100 and then have the user try to guess it.


Python Guessing Game


In this code, we first welcome the user and generate a random integer between 1 and 100 as the secret number. Then we give the user 5 chances to guess the number using a while loop. Inside the loop, we take the user's guess and compare it with the secret number. We give feedback to the user if their guess is too low or too high. If they guess the number right, we congratulate them and exit the loop using the break statement. If they exhaust all 5 guesses, we inform them that the game is over and reveal the secret number.