From df04c728d0f5bbce39677653fcd411a525a01f85 Mon Sep 17 00:00:00 2001 From: fadifadifadifadifadi157-glitch Date: Mon, 24 Aug 2026 23:45:22 +0500 Subject: [PATCH 1/6] Add high and low guess hints --- 1-Number_Guessing_Game.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/1-Number_Guessing_Game.py b/1-Number_Guessing_Game.py index 1d04694..24a8464 100644 --- a/1-Number_Guessing_Game.py +++ b/1-Number_Guessing_Game.py @@ -18,11 +18,13 @@ def number_guessing_game(): guess = int(input(" Enter your guess: ")) # Check if the guess is correct - if guess == secret_number: - print(f"Congratulations! You guessed the number {secret_number} correctly!") - break - else: - print("Sorry, Try again.") + if guess == secret_number: + print(f"Congratulations! You guessed the number {secret_number} correctly!") + break + elif guess < secret_number: + print("Too low! Try again.") + else: + print("Too high! Try again.") # Increase the number of attempts attempts += 1 From b773e53d983663a9b98bca9004a80420611ef276 Mon Sep 17 00:00:00 2001 From: fadifadifadifadifadi157-glitch Date: Tue, 25 Aug 2026 22:22:26 +0500 Subject: [PATCH 2/6] Handle invalid task number input --- 2-To-do-List.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/2-To-do-List.py b/2-To-do-List.py index 65effa9..f3bcd87 100644 --- a/2-To-do-List.py +++ b/2-To-do-List.py @@ -27,13 +27,18 @@ elif choice == "3": if not tasks: print("No tasks to delete!") - else: - task_number = int(input("🗑️ Enter task number to delete: ")) - if 1 <= task_number <= len(tasks): - deleted_task = tasks.pop(task_number - 1) - print(f"Task deleted: {deleted_task}") - else: - print("Invalid task number!") + else: + try: + task_number= int(input("🗑️ Enter task number to delete:")) + + if 1 <= task_number <=len(tasks): + deleted_task= tasks.pop(task_number - 1) + print(f"Task deleted: {deleted_task}") + else: + print("Invalid task number!") + + except ValueError: + print("Invalid input! Please enter a task number.") elif choice == "4": print("Exiting... Goodbye!") From d3930eee8a83e0d1364bd7ed390433c715f4452c Mon Sep 17 00:00:00 2001 From: Fowad Ajmal Date: Tue, 15 Sep 2026 21:13:20 +0500 Subject: [PATCH 3/6] Fix input handling and indentation --- 1-Number_Guessing_Game.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/1-Number_Guessing_Game.py b/1-Number_Guessing_Game.py index 24a8464..33c409f 100644 --- a/1-Number_Guessing_Game.py +++ b/1-Number_Guessing_Game.py @@ -15,16 +15,19 @@ def number_guessing_game(): while attempts < max_attempts: try: # Get user's guess - guess = int(input(" Enter your guess: ")) + guess = int(input("Enter your guess: ")) # Check if the guess is correct - if guess == secret_number: - print(f"Congratulations! You guessed the number {secret_number} correctly!") - break - elif guess < secret_number: - print("Too low! Try again.") - else: - print("Too high! Try again.") + if guess == secret_number: + print( + f"Congratulations! You guessed the number " + f"{secret_number} correctly!" + ) + break + elif guess < secret_number: + print("Too low! Try again.") + else: + print("Too high! Try again.") # Increase the number of attempts attempts += 1 @@ -37,11 +40,15 @@ def number_guessing_game(): print(f"Game over! The correct number was {secret_number}.") # Ask to play again - play_again = input("\n Do you want to play again? (yes/no): ").lower() + play_again = input( + "\nDo you want to play again? (yes/no): " + ).lower() + if play_again == "yes": number_guessing_game() else: print("Thanks for playing! Goodbye.") + # Run the game number_guessing_game() From 672b1f4e2fe39c0453c4d50d16be2ff921d37f98 Mon Sep 17 00:00:00 2001 From: Fowad Ajmal Date: Tue, 15 Sep 2026 21:16:03 +0500 Subject: [PATCH 4/6] Validate guesses within game range --- 1-Number_Guessing_Game.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/1-Number_Guessing_Game.py b/1-Number_Guessing_Game.py index 33c409f..cb2fe65 100644 --- a/1-Number_Guessing_Game.py +++ b/1-Number_Guessing_Game.py @@ -16,6 +16,9 @@ def number_guessing_game(): try: # Get user's guess guess = int(input("Enter your guess: ")) + if guess < 1 or guess > 10: + print("Please enter a number between 1 and 10.") + continue # Check if the guess is correct if guess == secret_number: From 2cb3a783096a5b5f2e956b6562465ec70e5b8318 Mon Sep 17 00:00:00 2001 From: Fowad Ajmal Date: Tue, 15 Sep 2026 21:18:11 +0500 Subject: [PATCH 5/6] Display remaining attempts --- 1-Number_Guessing_Game.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/1-Number_Guessing_Game.py b/1-Number_Guessing_Game.py index cb2fe65..275d56f 100644 --- a/1-Number_Guessing_Game.py +++ b/1-Number_Guessing_Game.py @@ -13,7 +13,9 @@ def number_guessing_game(): # Start the game loop while attempts < max_attempts: - try: + try: # Remaining Attempts + remaining_attempts = max_attempts - attempts + print(f"Attempts remaining: {remaining_attempts}") # Get user's guess guess = int(input("Enter your guess: ")) if guess < 1 or guess > 10: From 49a36f8b6a7bbb21402701c8a869d5c8f8ac03ba Mon Sep 17 00:00:00 2001 From: Fowad Ajmal Date: Tue, 15 Sep 2026 21:21:49 +0500 Subject: [PATCH 6/6] Improve game replay with loop --- 1-Number_Guessing_Game.py | 104 ++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 54 deletions(-) diff --git a/1-Number_Guessing_Game.py b/1-Number_Guessing_Game.py index 275d56f..fc5f197 100644 --- a/1-Number_Guessing_Game.py +++ b/1-Number_Guessing_Game.py @@ -1,59 +1,55 @@ import random + def number_guessing_game(): print("Welcome to the Number Guessing Game!") - print("I'm thinking of a number between 1 and 10...") - - # Generate a random number between 1 and 10 - secret_number = random.randint(1, 10) - - # Maximum number of attempts - max_attempts = 3 - attempts = 0 - - # Start the game loop - while attempts < max_attempts: - try: # Remaining Attempts - remaining_attempts = max_attempts - attempts - print(f"Attempts remaining: {remaining_attempts}") - # Get user's guess - guess = int(input("Enter your guess: ")) - if guess < 1 or guess > 10: - print("Please enter a number between 1 and 10.") - continue - - # Check if the guess is correct - if guess == secret_number: - print( - f"Congratulations! You guessed the number " - f"{secret_number} correctly!" - ) - break - elif guess < secret_number: - print("Too low! Try again.") - else: - print("Too high! Try again.") - - # Increase the number of attempts - attempts += 1 - - except ValueError: - print("Invalid input! Please enter a valid number.") - - # If max attempts reached and no correct guess - if attempts == max_attempts and guess != secret_number: - print(f"Game over! The correct number was {secret_number}.") - - # Ask to play again - play_again = input( - "\nDo you want to play again? (yes/no): " - ).lower() - - if play_again == "yes": - number_guessing_game() - else: - print("Thanks for playing! Goodbye.") - - -# Run the game + + while True: + print("\nI'm thinking of a number between 1 and 10...") + + secret_number = random.randint(1, 10) + max_attempts = 3 + attempts = 0 + + while attempts < max_attempts: + try: + remaining_attempts = max_attempts - attempts + print(f"Attempts remaining: {remaining_attempts}") + + guess = int(input("Enter your guess: ")) + + if guess < 1 or guess > 10: + print("Please enter a number between 1 and 10.") + continue + + if guess == secret_number: + print( + f"Congratulations! You guessed the number " + f"{secret_number} correctly!" + ) + break + + elif guess < secret_number: + print("Too low! Try again.") + + else: + print("Too high! Try again.") + + attempts += 1 + + except ValueError: + print("Invalid input! Please enter a valid number.") + + if attempts == max_attempts and guess != secret_number: + print(f"Game over! The correct number was {secret_number}.") + + play_again = input( + "\nDo you want to play again? (yes/no): " + ).lower() + + if play_again != "yes": + print("Thanks for playing! Goodbye.") + break + + number_guessing_game()