Guys we will be coding a game, where you get to guess the numbers and the output shall look like this:
Let’s Jump directly into the code section :
#This is a Number guessing game
import random
secret_number = random.randint(1,20)
print("I am thinking of a number between 1 and 20, guess the number")
#Ask for input from users and give them 6 tries
for guessesTaken in range(1,7):
print("take a guess")
guess = int(input())
if guess > secret_number:
print("Your guess is too high")
elif guess < secret_number :
print("Your guess is too low")
else:
break #in ths case guess = secret number
if guess == secret_number:
print("Awesome job, on guessing the number correctly, in " + str(guessesTaken) + " tries")
else :
print("The number i was guessing was " + str(secret_number))