This forum is now read-only. Please use our new forums! Go to forums
banner
Close banner
I am getting a syntax error for correct code?
I am currently doing 1.8 ‘Your own While/Else loop’ and when I run the code I get this error:
Traceback (most recent call last):
File "runner.py", line 96, in compilecode
File "python", line 8
if guess==random_number:
^
SyntaxError: invalid syntax
The code is:
from random import randrange
random_number = randrange(1, 10)
count = 0
while count < 3:
guess=int(raw_input('Enter a guess:')
if guess==random_number:
print "you win!"
break
count+=1
else:
print'you lose.'
I really have no idea what’s wrong with this code, can someone please help explain?
Answer 50a4f31c52ffbff3fd006059
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
1 comments
sweet, it’s all good now, thanks for the help.