diff --git a/Number/numbergame.py b/Number/numbergame.py index 077e209..bbe79c5 100644 --- a/Number/numbergame.py +++ b/Number/numbergame.py @@ -1,7 +1,34 @@ -SECRET = 777 +import random +import os +MAX_NUMBER = None + +def clear(): + if os.name == "nt": + os.system('cls') + else: + os.system('clear') +try: + CHOICE = int(input("Choose a difficulty between 1 and 3: ")) + clear() +except ValueError: + print("Invalid choice !") + input() + exit() +if CHOICE == 3: + MAX_NUMBER = 2000 +if CHOICE == 2: + MAX_NUMBER = 1500 +if CHOICE == 1: + MAX_NUMBER = 1000 +if MAX_NUMBER == None: + print("Invalid choice") + input() + exit() + +SECRET = random.randint(1,MAX_NUMBER) print("In this program you will need to guess the number I am thinking of") -print("I am thinking of a number between 1 and 800") +print(f"I am thinking of a number between 1 and {MAX_NUMBER}") while True: try: @@ -13,6 +40,7 @@ print("Your guess is too high! Please try again.") else: print("Well done!! Your guess is correct!") + input() break except ValueError: print("Please enter a valid number.")