On Mon, Dec 15, 2008 at 10:01 PM, Lee Meredith <tesujicam...@gmail.com>wrote:
> <snip> > the MOUSEBUTTONDOWN gives the black0 XandYpositions with the*.append* > how do I reference the address in the list by using XandYpositions > Then replace them or take it out off the list > > This code puts out an error when you hit the letter "b" This error is pretty verbose, as most python errors are: > Traceback (most recent call last): > File "C:/Users/Lee/Desktop/pyGame01/GO/GO_1_2_3.py", line 46, in <module> This line tells you that the offending statement, the one that "broke" your program/contained a bug is on line 46. Usually this is a pretty good place to start looking. > for stone in len(black0): That tells you the statement that broke > TypeError: 'int' object is not iterable This line tells you /why/ it broke, which is usually the most important bit, and this one gives you some good information. First off, it tells you the type of error, in this case TypeError. AFAIK, this means you tried to do something with a type that isn't allowed. In this case you tried to iterate over an integer. This doesn't work. Would you expect this to work? for num in 7: Hopefully your experience with python will tell you that it would be silly to think of such a thing.However, if you were to say: for num in range(0, 7): - that would be a little more sane. In this case, you are performing something similar to the prior example: you're trying to iterate over a single integer. len() returns the length of the list as an integer value. If you look at some of your other statements you have "for white in white0:" - a list is iterable, and white0 is a list. I hope this helps, Wayne > > > Which I'm not really sure what that means or how to remedy it as well > > Thank you everyone > > ## geting there black and white stones alternate now the issue > ## of taking the stones off the board > ## Or more precisely to .insert into the list at an address that I detected > by finding the X. and the Y. by using the > ## if event.pos == range( black0[stone][0] - (stoneWidth/2), > black0[stone][0] + ((stoneWidth/2)+1)): > import pygame > from pygame.locals import * > from sys import exit > pygame.init() > screen = pygame.display.set_mode((758, 758), 0, 32) > ##Color > color0 = (0,255) > > b = 0 > > white0 = [] #white0 > black0 = [] #black0 > > stoneWidth = 20 > > while True: > pressed_keys = pygame.key.get_pressed() > for event in pygame.event.get(): > if event.type == QUIT: > exit() > if event.type == MOUSEBUTTONDOWN:##makes a variable out of the X. > and Y. coordinates > if b==0: > b=1 > black0.append(event.pos)##black0.append [X. and Y.] > black1.append(event.pos) > print "black points1" > print black0 > print > else: > b=0 > white0.append(event.pos) > white1.append(event.pos) > print "white points" > print white0 > print > if event.type == KEYDOWN: > if event.key == K_b: > print "cut black" > for stone in len(black0):##I'm not sure here either is > this the way I would look for detection of mouse in the range > Circle if event.pos == range( black0[stone][0] - > (stoneWidth/2), black0[stone][0] + ((stoneWidth/2)+1)): > ## this is where I get confused what should I do > <<<<<<< > ## black0.insert(event.pos,0) > if event.pos == range( black0[stone][1] - > (stoneWidth/2), black0[stone][1] + ((stoneWidth/2)+1)): > ## this is where I get confused what should I do > <<<<<<< > ##black0.insert(event.pos,1) > > screen.fill((229,181,83)) > screen.lock() > for white in white0: #you're drawing > pygame.draw.circle(screen, (color0[1],color0[1],color0[1]), white, > 20) > for black in black0: > pygame.draw.circle(screen, (color0[0],color0[0],color0[0]), black, > 20) > screen.unlock() > pygame.display.update() > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > -- To be considered stupid and to be told so is more painful than being called gluttonous, mendacious, violent, lascivious, lazy, cowardly: every weakness, every vice, has found its defenders, its rhetoric, its ennoblement and exaltation, but stupidity hasn't. - Primo Levi
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor