Guessinggame (replace variable issue)
<p>so doing this for my stage 1 computer science paper. following code is what i've written atm. Line 16 (while statement) is giving a syntax error. The book asks us to</p>

<p>1) prompt the user to enter a guess and store the value in the "guess" variable,<br>
2) if guess is greater than goal print...<br>
3) if guess is lower than goal... print...<br>
4) if guess is same as goal, print...  </p>

<p>Unsure how to fix this. Any help will be greatly appreciated. Code as below.</p>

<pre><code>#Author: Anuj Saluja
#Date: 17 October 2016
import random

goal = random.randint(1,100)

guess = 0

print ("The object of this game is to")
print ("guess a number between 1 and 100")
print()

inputguess = int(input("Please guess the number: ")

while (guess != goal):
                 if inputguess &gt; goal
                 print ("Too high, try again.")
                 if inputguess &lt; goal
                 print ("Too low, try again.")
                 if inputguess == goal:
                 break
if inputguess == goal:
                 print ("Well done!")
                 print ("See you later.")
</code></pre>

<p>I think you are looking for this. hope this will work.    </p>

<pre><code>import random

goal = random.randint(1,100)

guess = 0

print ("The object of this game is to")
print ("guess a number between 1 and 100")

inputguess = int(input("Please guess the number: "))

while True:
    if inputguess &gt; goal:
        inputguess = int(input("Too high, try again: "))

    elif inputguess &lt; goal:
        inputguess = int(input("Too low, try again: "))

    elif inputguess == goal:
        print ("Well done!")
        print ("See you later.")
        break
</code></pre>

python python-3.x