214k views
0 votes
Can someone tell me what’s wrong with this?

def main():

# Initialize variables
numGuesses = 0
userGuess = -1
secretNum = 5


while secretNum!= userGuess:
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.")


main()

User NargesooTv
by
4.9k points

1 Answer

4 votes

This code is running without any syntax error. All I did is indented the code correctly. (Look at the attachement.)

Can someone tell me what’s wrong with this? def main(): # Initialize variables numGuesses-example-1
User Mdebeus
by
5.1k points