Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Guess_the_number/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions Guess_the_number/guess_the_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import random

number_to_guess = random.randint(0, 20)
count_of_tries = 1
print("----------------WELCOME---------------")
print("\nYou only have 5 turns.Good Luck!")
print(" ")
print(" ")
play = True
guess = int(input("Enter a number to guess : "))

while guess != number_to_guess:
print("Sorry wrong number")
print(" ")
if count_of_tries == 5:
break
elif guess == -1:
print("cheat mode activated your number is :", number_to_guess)
print(" ")
elif guess < number_to_guess:
print("Try higher number")
print(" ")

else:
print("Try lower number")
print(" ")
guess = int(input("Enter a number to guess : "))
count_of_tries += 1

if guess == number_to_guess:
print("Well done")
print(" ")
print("You took", count_of_tries)
print(" ")
else:
print("Oh no")
print(" ")
print("Number is", number_to_guess)
print(" ")

print("-----------------GAME ENDS-------------- ")