Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6fb3a8d

Browse filesBrowse files
committed
added input number control
1 parent 040f2a0 commit 6fb3a8d
Copy full SHA for 6fb3a8d

File tree

1 file changed

+3
-0
lines changed
Filter options

1 file changed

+3
-0
lines changed

‎number-guess/number_guess.py

Copy file name to clipboardExpand all lines: number-guess/number_guess.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def guess_the_number():
1717

1818
try:
1919
guess_number = int(input(f"Attempt {attempts + 1}/{max_attempts} - Guess the number: "))
20+
if guess_number < 1 or guess_number > 100:
21+
print("Invalid input! Please enter a number between 1 and 100.")
22+
continue
2023
attempts += 1
2124
except ValueError:
2225
print("Only integer values are allowed! Please try again.")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.