Oct-19-2021, 11:37 PM
Wow. I didn't know there were different kinds of quotation marks. Thanks for showing me that!
But I fixed the code so that all the quotation marks are the right kind, and it doesn't change how the program runs. It still prints everything all at once when the secret number is guessed.
By the way, I'm running my code with "Python Idle". That's what they have us using for the class. I don't know if that makes a difference.
Here's the code with the quotes fixed.
But I fixed the code so that all the quotation marks are the right kind, and it doesn't change how the program runs. It still prints everything all at once when the secret number is guessed.
By the way, I'm running my code with "Python Idle". That's what they have us using for the class. I don't know if that makes a difference.
Here's the code with the quotes fixed.
# Heading (WC,9/13/21,) feel free to use multiple lines 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("Hello, " + (name) + ".") print("You guessed the secret number.") print("It is true that the secret number was " + str(secretNum) + ".") print("It took you " + str(numGuesses) + " tries.") main()