Please I have a problem with Python functions and return.
from graphics import*
win = GraphWin('Me',640,160)
mylist=[]
def move_ob(ob):
ob.move(4,0)
return ob
def circle():
for x in range (10,200,10):
for y in range (10,200,10):
c =Circle (Point(x,y),5)
c.draw(win)
mylist.append(c)
def main():
circle()
win.getMouse()
move_ob(mylist)
win.getMouse()
win.close()
main()
What I ever I do it gives me this Error
ob.move(4,0)
AttributeError: 'list' object has no attribute 'move'
PS: that Library is from the book of John Zelle, learning python basics..
I want to make those circles I make move…
You are passing in
mylist, which is alist. Lists have no idea whatmoveis.I assume you want to move all the circles in the list. Therefore, you might want:
Rather than
move_ob(mylist).