Find the best solutions to your questions at Westonci.ca, the premier Q&A platform with a community of knowledgeable experts. Connect with a community of experts ready to help you find accurate solutions to your questions quickly and efficiently. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately.
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
Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. We hope this was helpful. Please come back whenever you need more information or answers to your queries. Thank you for trusting Westonci.ca. Don't forget to revisit us for more accurate and insightful answers.