Python Forum

Full Version: SyntaxError: multiple statements found while compiling a single statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This code works on Codecademy, but when I use it in Python I get an error message:
SyntaxError: multiple statements found while compiling a single statement
Why doesn't this code work in Python? Here is the code.
mylist = [2, 3, 4]
result = []
for number in mylist:
  result.append(number*2)
print result 
Always post the error traceback in it's entirity and unmodified.
This code should run fine in python 2.7
in python 3, you have to modify the print statement to:
print(result)
.

FIY: indentation should be 4 spaces, as per PEP8.