Umaru Ren Umaru Ren - 2 years ago 80
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")
print("Your Wrong")

Answer Source

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

  File "", 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":
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download