Solution to Number Guessing Game using Random package in Python

Here is the solution to Number Guessing Game using Random package in Python which is given below:

import random

print(“Welcome to the number guessing game!”)
randrange = int(input("Enter a range: "))
numbertoguess = random.randrange(randrange)

chances = int(input("Enter number of chances: "))

guesscounter = 0

while guesscounter < chances:

guesscounter += 1
myguess = int(input('Please Enter your Guess : '))

if myguess == numbertoguess:
    print(f'The number is {numbertoguess} and you found it right !! in the {guesscounter} attempt')
    break

elif guesscounter >= chances and myguess != numbertoguess:
    print(f'Oops sorry, The number is {numbertoguess} better luck next time')

elif myguess > numbertoguess:
    print('Your guess is higher ')

elif myguess < numbertoguess:
    print('Your guess is lesser')