Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions Number/numbergame.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
SECRET = 777
import random
import os

Check failure on line 2 in Number/numbergame.py

View workflow job for this annotation

GitHub Actions / ruff_check

ruff (I001)

Number/numbergame.py:1:1: I001 Import block is un-sorted or un-formatted help: Organize imports
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()

Check failure on line 16 in Number/numbergame.py

View workflow job for this annotation

GitHub Actions / ruff_check

ruff (PLR1722)

Number/numbergame.py:16:4: PLR1722 Use `sys.exit()` instead of `exit` help: Replace `exit` with `sys.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()

Check failure on line 26 in Number/numbergame.py

View workflow job for this annotation

GitHub Actions / ruff_check

ruff (PLR1722)

Number/numbergame.py:26:4: PLR1722 Use `sys.exit()` instead of `exit` help: Replace `exit` with `sys.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:
Expand All @@ -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.")
Loading