Discover a world of knowledge at Westonci.ca, where experts and enthusiasts come together to answer your questions. Connect with professionals on our platform to receive accurate answers to your questions quickly and efficiently. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.
Sagot :
Answer:
def main():
# Initialize variables
numGuesses = 0
userGuess = -1
secretNum = 5
name = input("Hello! What is your name?")
while ( userGuess != secretNum):
userGuess = int(input("Guess a number between 1 and 20: "))
numGuesses = numGuesses + 1
if (userGuess < secretNum):
print("You guessed " + str(userGuess) + ". Too low.")
if (userGuess > secretNum):
print("You guessed " + str(userGuess) + ". Too high.")
print("You guessed " + str(userGuess) + ". The correct number is " + secretNum + " after " + numGuess + " times.")
main()
Explanation:
add a While until userGuess == secretNum than we stop
We hope our answers were useful. Return anytime for more information and answers to any other questions you have. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.