Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Ammars branch #3

wants to merge 4 commits into from

Conversation

AmmarDagha
Copy link
Collaborator

No description provided.

guess = int(input("Enter an integer from 0 to 10: "))
numofguesses = 0

while number != guess:
Copy link
Owner

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.

Copy link
Collaborator Author

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)
Copy link
Owner

@anushacassum anushacassum Jun 29, 2021

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
Copy link
Owner

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?"

Copy link
Collaborator Author

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants