SyntaxError: multiple statements found while compiling a single statement

Steve D'Aprano steve+python at pearwood.info
Sun Oct 9 02:41:43 EDT 2016


On Sun, 9 Oct 2016 02:51 pm, Cai Gengyang wrote:

> I defined both done and pygame in this piece of code, but now i get a new
> error that i have never seen before, an AttributeError

AttributeError usually means you have the wrong kind of object:

py> mylist = {}  # oops, a dict not a list
py> mylist.append(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'dict' object has no attribute 'append'


or sometimes you have the right object but misspelled the attribute or
method:

py> mylist = []
py> mylist.apend(1)  # oops, spelling error
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'apend'
py> mylist.append(1)
py> print(mylist)
[1]



>>>> rect_x = 50
>>>> rect_y = 50
>>>> done = False
>>>> pygame = True

Why have you defined pygame = True? Is that what the code on the website
does?

My guess is that you are supposed to say:

import pygame



Why don't you try my suggestion of saving the code into a .py file, then
using the File > Open command to open it?




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list