View Single Post
Old May 14th, 2006, 6:47 AM   #21
commodore
Programmer
 
Join Date: Nov 2005
Location: Estonia
Posts: 97
Rep Power: 0 commodore is an unknown quantity at this point
I was trying to do mrynit's bob, bill and joe thingie, but it doesn't append the last elif person
bob=['hammer', 'saw']
joe=['saw', 'drill', 'leveler']
bill=['hammer', 'leveler']
everyone=[bob, joe, bill]
countOverall=len(bob)+len(joe)+len(bill)
everyoneString=' '.join(bob+joe+bill)

def toolcount(tool):
    count=0
    finding=everyoneString.find(tool)
    while finding!=-1:
        count+=1
        start=finding+1
        finding=everyoneString.find(tool, start)
    return count

def whoowns(tool):
    owners=[]
    if ' '.join(bob).find(tool)!=-1:
        owners.append('bob')
    elif ' '.join(bill).find(tool)!=-1:
        owners.append('bill')
    elif ' '.join(joe).find(tool)!=-1:
        owners.append('joe')
    print owners

whoowns('leveler')
commodore is offline   Reply With Quote