Umaru Ren Umaru Ren - 6 months ago 11
Python Question

Syntax error on line containing if statement

I keep trying to make a simple guess the number game but Python keeps saying my code has a syntax error. What am I doing wrong?

import random
takeone = input("Guess A Number Between 1 & 5")
numberinit = random.randint(1,5)
if "takeone" == "numberinit"
print("Your Right")
else:
print("Your Wrong")

Answer

The syntax error you're getting is probably something like the following:

  File "test.py", line 4
    if "takeone" == "numberinit"
                               ^    
SyntaxError: invalid syntax

This means you're missing a colon at the end of the if line. The line should instead read:

if "takeone" == "numberinit":