-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ammars branch #3
base: main
Are you sure you want to change the base?
Conversation
guess = int(input("Enter an integer from 0 to 10: ")) | ||
numofguesses = 0 | ||
|
||
while number != guess: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be easier to use a for loop that runs 8 times? And finishes? Since the player can no longer enter guesses after trying 8 times?
Using a while loop means allowing the loop to run infinitely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that makes more sense.
guess = int(input("Enter an integer from 0 to 10: ")) | ||
if numofguesses == 7: | ||
print("You have failed to guess the number") | ||
print("The number was : ", number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point the loop should break. And the user should not be allowed to enter more numbers as the game is over.
while number != guess: | ||
print ("Sorry, try again!") | ||
guess = int(input("Enter an integer from 0 to 10: ")) | ||
numofguesses = numofguesses + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the user guesses the correct number on the 5th try? Why does he/she still get the "Do you want a hint message?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add the condition "if numofguesses == 4 and number != guess"
No description provided.