Guess a number game in python

 from random import randint

beg=int(input("Enter a number where you want to begin"))

end=int(input("Enter a number where you want to end"))

def choose_num(n):

  r=randint(beg,end)

  if n>=beg and n<=end:

    if n==r:

      print("Congrats you guess it! ")

      print()

    else:

      print("Number is",r, "try again")

      print()

  else:

    print("Sorry number is out of range")

    print()

n=0

while True:

  if n!=-1:

     n=int(input("Guess a number"))

     choose_num(n)

  else:

    break


Comments

Popular posts from this blog

Create account in java |deposit money|withdraw money

Library Management System in python OOPs Concept

List comprehension hackerrank solution in python