Hi everyone, I am new to Python. Been poking at it for about a month now. I am trying to set up a list for information on people. For example: person 0's name = "Sam". li[0][0] person 0's hoppy = "skateboarding" li[0][1] person 0's favorite color = ["green", "red"] li[0][2] # it appears i can put another list inside of the list, ie li[0][2]=[x,y,z] very cool! we couldn't do that in my grandpa languages. Would that be done with a li[0].append(['green','red']) after I'm done defining li[0][1]?? Then, I could just do a li[0][2].extend(['purple','mauve']) if more colors were ever needed? person 0's favorite numbers = [1, 3, 5-10, 78] li[0][3] # ranges of numbers? person 1's name = "Mary" li[1][0] etc..
My thought if there's not already an elegant solution in Python is to create a flag 'r' before ranges. So, the example here would become [1,3,'r',5,10,18,78]. Then I just do a > < query to find a match. How does that sound? newNum = 8 numHit = False for i in range(len(li[x][3])): if li[x][3][i] == 'r': if li[x][3][i+1] < newNum > li[x][3][i+2]: # I didn't do <= and >= because the = parts will be evaluated in the next 2 iterations of the loop numHit == True else: if newNum == li[x][3][i]: numHit == True if numHit: print "You picked one of " + li[x][0] + "'s lucky numbers!" How does that look? Is that ~ the best way to address my problem? Thanks! Michael
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32