Share your repls and programming experiences

← Back to all posts
Random Work
Wizardbluske (0)

Not getting it actually, i got some help from the recommended sites.
import random

number = random.randint(1,10)

print "The computer will generate a random number between 1 and 10. Try to guess the number!"

guess = int(raw_input("Guess a number: "))

while guess != number:
if guess >= 1 and guess <= 10:
print "Sorry, you are wrong."
guess = int(raw_input("Guess another number: "))
elif guess <= 0 and guess >= 11:
print "That is not an integer between 1 and 10 (inclusive)."
guess = int(raw_input("Guess another number: "))

if guess == number:
print "Congratulations! You guessed correctly!"

Commentshotnewtop
Axrevyn (223)

You need parentheses to print().
This code might work for some versions of Python -

print "Hello World"

But in the version you have this project in, you need to use parentheses or you'll get that SyntaxError.

print("Hello World")
k9chelsea2 (654)

as axrevyn said its because of the missing brackets on line 6